Solved Single-user mode & restarting Internet without rebooting

About dropping into single-user mode without rebooting. Then when going into multi user mode, restarting the Internet connection afterwards or otherwise after using commands to take computer offline.

init 1 will drop you into single-user mode without rebooting. You may want to close your applications first. In single user mode, the only user is root. See: init(8).
exit will get you back into multi-user mode.

Once back to multi-user mode, you have to type service netif restart && service routing start. You also have to use these command to bring your network back up after taking your computer offline, such as for adjusting your firewall and adjusting network configurations. Sometimes you want to disconnect your computer from the Internet to secure your computer settings. The routing script fixes network connectivity so it continues to work each time, but doesn't stay enabled. The routing service(8) is in /etc/rc.d/ and can also be found with service -l | grep routing. You may also have to restart your application, such as browser, for it to take notice of the setting. There may be something missing for this to be complete, because some websites work, while others don't.

On other operating systems, after attempting to reconnect to the Internet, OS connectivity to the network occurs more automatically on its own, but on FreeBSD, it's not obvious.
 
Isnt't there /etc/netstart?
While it's convenient, it worked the same way. I suspect that IPv6 capable websites are working, and IPv4 only websites aren't working. Something is in the reboot, that's not in netstart, or I have something misconfigured. Still, that it works on reboot, means a possible misconfiguration is minor and isn't enough to stop it from working correctly there.

When I ping websites which don't show up in the browser, I get:
Code:
ping: sendto: No route to host
traceroute6 on addresses which don't work, show those hostnames don't support IPv6. When using traceroute on one of these sites which doesn't work, it states a website has multiple addresses; and which one it's using. The next line has:
Code:
traceroute: findsaddr: failed to connect to peer for src addr selection.
 
/etc/netstart does clean up and re-init my firewall, maybe there is some residue blocking the pipes, so to speak?
 
Honest question, I'm curious: what is difference between init 1 and shutdown now?
I was under impression that shutdown will have more messages written in the system log?

BTW I'm using single user only for kernel/world reinstalls in STABLE - make buildworld; make buildkernel; shutdown now; cd /usr/src; make installkernel; shutdown -r now; ### login as user(operator) ###;shutdown now; etcupdate -p; cd /usr/src; make installworld; etcupdate -B; shutdown -r now . I know that handbook says that going single-user is needed only for 26.8. but I'm doing it as a hail to old Gods 😇 and doing this way seems to be very vmisev proof, regardless of 26.6.1. doing it all in multi-user.

P.S. Sorry for thread hijack, but I'm really curios about init 1 and shutdown now difference 🤷‍♂️
 
I use this alias if i need to restart the network (not dhcp, statically-configured).
Code:
% alias restartnet
service netif restart && service routing restart

I've recently discovered on my own how to boot into single-user mode from already booted multi-user mode, it's a good way but i'd like to sync everything before going into it, like # shutdown -p now does before actual poweroff so no data can get corrupted in such operations.

I don't need to get into single-user mode to restart the network, though.
 
Honest question, I'm curious: what is difference between init 1 and shutdown now?
I was under impression that shutdown will have more messages written in the system log?
Unless things have changed, when you are booted into "multiuser mode" (or what used to be called run level 3 or better), "init 1" drops the system to single user mode without rebooting. "shutdown" obviously shuts the system down, then reboots if you did "-r" or powers off if you did "-p". When OP does "init 1 && do some stuff && exit" the system winds up back at it's previous runlevel (likely 3 or better).
 
Unless things have changed, when you are booted into "multiuser mode" (or what used to be called run level 3 or better), "init 1" drops the system to single user mode without rebooting. "shutdown" obviously shuts the system down, then reboots if you did "-r" or powers off if you did "-p". When OP does "init 1 && do some stuff && exit" the system winds up back at it's previous runlevel (likely 3 or better).
This is exactly how shutdown now (without any options) works, and exit will get you back to multi-user. As per shutdown(8):
When run without options, the shutdown utility will place the system into single user mode at the time specified.
 
  • Like
Reactions: mer
This is exactly how shutdown now (without any options) works, and exit will get you back to multi-user. As per shutdown(8):
Interesting; I never noticed that probably because I "always" run shutdown with either "-r" or "-p" and the last time I dropped to single user mode was because I was mucking with immutable flags on system files.
 
kill 1
should go to single user mode too :)
For that you must be root or use sudo, for shutdown is enough that user is in operator group. That's why I always shutdown -r now instead of sudo reboot. BTW, poweroff is okay for the operator as well.
 
  • Thanks
Reactions: mro
Interesting; I never noticed that probably because I "always" run shutdown with either "-r" or "-p" and the last time I dropped to single user mode was because I was mucking with immutable flags on system files.
That's why I posted my bildworld/buildkernel example in #5, not to brag, but to illustrate my use case.
 
  • Like
Reactions: mer
I'm not sure if I rebooted, or if it ended up working on its own. The purpose is to go into single user mode back into multiuser mode without rebooting, that includes getting the network back up without rebooting.

Based on my results from ping and traceroute, what causes websites without IPv6 ability to not work, after turning off the network through command line?

% alias restartnet service netif restart && service routing restart
Tried the commands as written. /etc/netstart covers that also. For a secure user, could do doas for dropping into single user mode and for restarting Internet. It can be set to require the password for single user mode anyway. It can be so, it doesn't ask for it twice.
 
I'm not sure if I rebooted, or if it ended up working on its own. The purpose is to go into single user mode back into multiuser mode without rebooting, that includes getting the network back up without rebooting.

Based on my results from ping and traceroute, what causes websites without IPv6 ability to not work, after turning off the network through command line?


Tried the commands as written. /etc/netstart covers that also. For a secure user, could do doas for dropping into single user mode and for restarting Internet. It can be set to require the password for single user mode anyway. It can be so, it doesn't ask for it twice.
I'm having trouble to understand what actual problem is? I just tried sudo init 1 , exit, startx (witthout any service * restart ) and Brave had no problem accessing github and reddit which, according to IPv6 Compatibility Checker are not IPv6 compatible? What I'm missing?
 
May I ask why do you have to boot into single-user mode to restart the network?
Because after using service netif restart and service routing restart or /etc/netstart, a lot of websites don't work for my computer. It seems that sites that include IPv6 ability work, while sites that only have IPv4 ability don't work. It's like the IPv6 part sets it up for them so it can work in IPv4 from my computer.

I'm using 14.3. idk if my settings are incorrect, but something is missing in netstart, which happens on a reboot. I have to reboot for all websites to work, because those commands don't do it.

I just tried sudo init 1, exit, startx (witthout any service * restart)
Dropping into single user mode drops the network? It needs to be started, after coming back from single user mode.
 
Because after using service netif restart and service routing restart or /etc/netstart, a lot of websites don't work for my computer.
If you are using DHCP, can you try # service dhclient restart? That command was fixing that problem when I was using DHCP and used "restartnet" alias.
 
Now it's working, before I got to that. It must have been a resolv.conf setting I temporarily had. Even though I restarted that too before. It could have been an rc.conf setting for my default gateway.

If you are using DHCP, can you try # service dhclient restart? That command was fixing that problem when I was using DHCP and used "restartnet" alias.
requires setting up /etc/dhclient.conf to specify the interface.
 
Dropping into single user mode drops the network. It needs to be started, after coming back from single user mode.
Well, not for me, I forgot to mention that after I sudo init 1 I tried ping on LAN address and ping on google, both worked, then I did exit, logged in as user, and first command that I typed was startx and immediately started Brave, which was accessing both github and reddit without any problems. I had no need to restart any service manually after coming back to multi-user from single-user mode, that's why I'm confused?
 
Well, not for me, I forgot to mention that after I sudo init 1 I tried ping on LAN address and ping on google, both worked, then I did exit, logged in as user, and first command that I typed was startx and immediately started Brave, which was accessing both github and reddit without any problems. I had no need to restart any service manually after coming back to multi-user from single-user mode, that's why I'm confused?
I'm used to when booting into single user mode, that the network doesn't come up.

In my case, when dropping into single user mode, back into multi user mode, I had to restart everything. It might have been a slightly misconfigured setting, which, when rebooting covers it. Trying single user mode again without rebooting, there were a few network services on there. I believe these aren't there when booting directly into single user mode.

I still need to be able to get an Internet up without rebooting, for whatever reason I turned my internet off or changed a setting. So far, this is done. There is still room for improvement to find out what booting does better than /etc/netstart for Internet service. This is enough for me for now.
 
I'm used to when booting into single user mode, that the network doesn't come up.
Booting into single-user is very, very different from dropping from multi-user to single-user.

My settings are very simple, dhclient.conf is empty, reslov.conf has only three nameserever lines, all pointing to my ISP DNS, and in rc.conf I have only ifconfig_em0="DHCP -lro -tso"
 
A separate issue that popped up, when exiting from single user mode. Ctrl-Alt F keys stopped working. I ended up having to reboot anyway.
 
Back
Top