# Script(s) that start networking in multi-user mode



## Niatross (Oct 11, 2013)

What script(s) starts networking in multi-user mode? I see a NETWORKING script under /etc/rc.d. 

I looked in my /etc/defaults/rc.conf file but I don't see any variables that are enabled to get networking started.

BTW: I can use the following command to start networking in single-user mode:


```
/etc/rc.d/netif start && /etc/rc.d/routing start
```


----------



## kpa (Oct 12, 2013)

The NETWORKING file is a "pseudo target" to act as a marker for scripts that have to be for example started after networking has been set up. To get a good picture of which /etc/rc.d/* scripts get run at start up and in which order you can run this on your system:

`rcorder  /etc/rc.d/* /usr/local/etc/rc.d/*`

The bulk of the code that implements the functions for the networking scripts netif and routing is in /etc/network.subr.


----------



## ShelLuser (Oct 12, 2013)

What makes you think that the normal operation mode would use different scripts than the single user mode? Single user mode is basically nothing more than the same kind of environment yet with most daemons shut down.

Alas; if you take a closer look at /etc/rc.d/NETWORKING you'll see exactly which scripts are required for full networking operations:


```
# REQUIRE: netif netoptions routing ppp ipfw stf faith
# REQUIRE: defaultroute routed mrouted route6d mroute6d resolv bridge
# REQUIRE: static_arp static_ndp
```


----------



## kpa (Oct 12, 2013)

FYI FreeBSD does not have runlevels. The single user mode is just the same as multiuser mode in every other way but none of the rc(8) scripts are run when booting in single user mode.


----------



## Niatross (Oct 12, 2013)

kpa said:
			
		

> The NETWORKING file is a "pseudo target" to act as a marker for scripts that have to be for example started after networking has been set up.



What are you talking about man? Speak in English. Give it to me in layman's terms.

When rc(8) runs ... what script does it look at first and how many scripts does it run until networking is up an running on a FreeBSD system?


----------



## ShelLuser (Oct 12, 2013)

Niatross said:
			
		

> When rc(8) runs ... what script does it look at first and how many scripts does it run until networking is up an running on a FreeBSD system?


Uhm, didn't we already address this in another thread?


----------



## Niatross (Oct 13, 2013)

How many scripts does it take to to bring networking up?

Does rc run /etc/rc.d/NETWORKING first and then the following scripts to bring networking up:


```
# netif, netoptions, routing, ppp , pfw, stf, faith, defaultroute, routed, mrouted, route6d, mroute6d, resolv, bridge, static_arp and static_ndp
```


----------



## junovitch@ (Oct 13, 2013)

Niatross said:
			
		

> How many scripts does it take to to bring networking up?
> 
> Does rc run /etc/rc.d/NETWORKING first and then the following scripts to bring networking up:
> 
> ...



It's the other way around.  Run `service -r` to see the boot time order and you'll see how it goes.


----------



## Niatross (Oct 15, 2013)

How come I don't see /etc/rc.d/netif  or /etc/rc.d/routing listed when I run service -e

I don't even see any of the other networking services (mentioned in this thread) when I run service -e.

I don't even see any processes for these network services when I run ps aux.

How come?


----------



## junovitch@ (Oct 15, 2013)

Don't read too much into the name service. It doesn't imply that it is a background daemon and should have a process. In most cases all the networking is fire and forget when the system starts. If you are using routed or dhclient then those processes will continue to run in the background.

As far as service -e, see service().  It's explained right there.


----------



## Niatross (Oct 16, 2013)

rc(8) runs through each script in the /etc/rc.d and /usr/local/etc/rc.d. My question is:

What log can I view that verifies that each of the following scripts were "actually" run:


```
netif, netoptions, routing, ppp , pfw, stf, faith, defaultroute, routed, mrouted, route6d, mroute6d, resolv, bridge, static_arp and static_ndp
```

Some of these scripts are not run as a daemon (AKA: service), so how do I know rc(8) "actually" ran these networking scripts (above)?

I want some type of verification.

I normally can run "service -e" or "ps aux" to verify that a script (in /etc/rc.d or /usr/local/etc/rc.d)  has been run "successfully" by  rc(8).


----------



## ShelLuser (Oct 16, 2013)

Simple. Use the appropriate networking tools and look at the results. ifconfig tells you all about your network interfaces and if those have any addresses assigned to them, route or netstat can tell you everything about routing tables (and a whole lot more when using netstat), and so on.

Another option is to check the appropriate logfiles. /var/log/messages for example will show some comments regarding the network, /var/log/dmesg.today will contain output from network options, /var/log/mount.today the filesystem options, and so on.


----------



## junovitch@ (Oct 17, 2013)

Since they log to the console when the system starts, enabling capturing the console log to a file may give you what you want.  See syslog.conf() or really just read /etc/syslog.conf about un-commenting the console log and creating the file with touch followed by fixing permissions with chmod.  That's the first thing that comes to my mind but not all the scripts may provide a verbose enough output by default if that is what you are looking for.  If anything else comes to mind I'll chime back in with that as well.


----------

