4 # From: @(#)netstart 5.9 (Berkeley) 3/30/91
6 # Note that almost all of the user-configurable behavior is no longer in
7 # this file, but rather in /etc/defaults/rc.conf. Please check that file
8 # first before contemplating any changes here. If you do need to change
9 # this file for some reason, we would like to know about it.
11 # First pass startup stuff.
14 echo -n 'Doing initial network setup:'
16 # Set the host name if it is not already set
18 if [ -z "`hostname -s`" ]; then
23 # Set the domainname if we're using NIS
25 case ${nisdomainname} in
29 domainname ${nisdomainname}
36 # Initial ATM interface configuration
40 if [ -r /etc/rc.atm ]; then
47 # Special options for sppp(4) interfaces go here. These need
48 # to go _before_ the general ifconfig section, since in the case
49 # of hardwired (no link1 flag) but required authentication, you
50 # cannot pass auth parameters down to the already running interface.
52 for ifn in ${sppp_interfaces}; do
53 eval spppcontrol_args=\$spppconfig_${ifn}
54 if [ -n "${spppcontrol_args}" ]; then
55 # The auth secrets might contain spaces; in order
56 # to retain the quotation, we need to eval them
58 eval spppcontrol ${ifn} ${spppcontrol_args}
62 # Set up all the network interfaces, calling startup scripts if needed
64 case ${network_interfaces} in
66 network_interfaces="`ifconfig -l`"
71 for ifn in ${network_interfaces}; do
72 if [ -r /etc/start_if.${ifn} ]; then
73 . /etc/start_if.${ifn}
77 # Do the primary ifconfig if specified
79 eval ifconfig_args=\$ifconfig_${ifn}
81 case ${ifconfig_args} in
85 # DHCP inits are done all in one go below
86 dhcp_interfaces="$dhcp_interfaces $ifn"
90 ifconfig ${ifn} ${ifconfig_args}
96 if [ ! -z "${dhcp_interfaces}" ]; then
97 ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
100 for ifn in ${network_interfaces}; do
101 # Check to see if aliases need to be added
105 eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
106 if [ -n "${ifconfig_args}" ]; then
107 ifconfig ${ifn} ${ifconfig_args} alias
109 alias=`expr ${alias} + 1`
115 # Do ipx address if specified
117 eval ifconfig_args=\$ifconfig_${ifn}_ipx
118 if [ -n "${ifconfig_args}" ]; then
119 ifconfig ${ifn} ${ifconfig_args}
124 for ifn in ${network_interfaces}; do
125 eval showstat=\$showstat_${ifn}
126 if [ ! -z ${showstat} ]; then
131 # ISDN subsystem startup
133 case ${isdn_enable} in
135 if [ -r /etc/rc.isdn ]; then
141 # Warm up user ppp if required, must happen before natd.
143 case ${ppp_enable} in
145 # Establish ppp mode.
147 if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
148 -a "${ppp_mode}" != "dedicated" \
149 -a "${ppp_mode}" != "background" ]; then
153 ppp_command="-${ppp_mode} ";
155 # Switch on alias mode?
159 ppp_command="${ppp_command} -nat";
163 echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
167 # Initialize IP filtering using ipfw
171 if /sbin/ipfw -q flush > /dev/null 2>&1; then
177 case ${firewall_enable} in
179 if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
181 echo "Kernel firewall module loaded."
182 elif [ "${firewall_in_kernel}" -eq 0 ]; then
183 echo "Warning: firewall kernel module failed to load."
188 # Load the filters if required
190 case ${firewall_in_kernel} in
192 if [ -z "${firewall_script}" ]; then
193 firewall_script=/etc/rc.firewall
196 case ${firewall_enable} in
198 if [ -r "${firewall_script}" ]; then
199 . "${firewall_script}"
200 echo -n 'Firewall rules loaded, starting divert daemons:'
202 # Network Address Translation daemon
204 case ${natd_enable} in
206 if [ -n "${natd_interface}" ]; then
207 if echo ${natd_interface} | \
208 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
209 natd_ifarg="-a ${natd_interface}"
211 natd_ifarg="-n ${natd_interface}"
214 echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
221 elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
222 echo -n "Warning: kernel has firewall functionality, "
223 echo "but firewall rules are not enabled."
224 echo " All ip services are disabled."
231 # Additional ATM interface configuration
233 if [ -n "${atm_pass1_done}" ]; then
239 case ${defaultrouter} in
243 static_routes="default ${static_routes}"
244 route_default="default ${defaultrouter}"
248 # Set up any static routes. This should be done before router discovery.
250 if [ -n "${static_routes}" ]; then
251 for i in ${static_routes}; do
252 eval route_args=\$route_${i}
253 route add ${route_args}
257 echo -n 'Additional routing options:'
258 case ${tcp_extensions} in
262 echo -n ' tcp extensions=NO'
263 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
267 case ${icmp_bmcastecho} in
269 echo -n ' broadcast ping responses=YES'
270 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
274 case ${icmp_drop_redirect} in
276 echo -n ' ignore ICMP redirect=YES'
277 sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
281 case ${icmp_log_redirect} in
283 echo -n ' log ICMP redirect=YES'
284 sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
288 case ${gateway_enable} in
290 echo -n ' IP gateway=YES'
291 sysctl -w net.inet.ip.forwarding=1 >/dev/null
295 case ${forward_sourceroute} in
297 echo -n ' do source routing=YES'
298 sysctl -w net.inet.ip.sourceroute=1 >/dev/null
302 case ${accept_sourceroute} in
304 echo -n ' accept source routing=YES'
305 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
309 case ${tcp_keepalive} in
311 echo -n ' TCP keepalive=YES'
312 sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
316 case ${tcp_restrict_rst} in
318 echo -n ' restrict TCP reset=YES'
319 sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
323 case ${tcp_drop_synfin} in
325 echo -n ' drop SYN+FIN packets=YES'
326 sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
330 case ${ipxgateway_enable} in
332 echo -n ' IPX gateway=YES'
333 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
337 case ${arpproxy_all} in
339 echo -n ' ARP proxyall=YES'
340 sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
345 echo -n 'routing daemons:'
346 case ${router_enable} in
348 echo -n " ${router}"; ${router} ${router_flags}
352 case ${ipxrouted_enable} in
355 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
359 case ${mrouted_enable} in
361 echo -n ' mrouted'; mrouted ${mrouted_flags}
365 case ${rarpd_enable} in
367 echo -n ' rarpd'; rarpd ${rarpd_flags}
372 # Let future generations know we made it.
374 network_pass1_done=YES
378 echo -n 'Doing additional network setup:'
379 case ${named_enable} in
381 echo -n ' named'; ${named_program:-named} ${named_flags}
385 case ${ntpdate_enable} in
388 ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
392 case ${xntpd_enable} in
394 echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
398 case ${timed_enable} in
400 echo -n ' timed'; timed ${timed_flags}
404 case ${portmap_enable} in
406 echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
410 # Start ypserv if we're an NIS server.
411 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
413 case ${nis_server_enable} in
415 echo -n ' ypserv'; ypserv ${nis_server_flags}
417 case ${nis_ypxfrd_enable} in
419 echo -n ' rpc.ypxfrd'
420 rpc.ypxfrd ${nis_ypxfrd_flags}
424 case ${nis_yppasswdd_enable} in
426 echo -n ' rpc.yppasswdd'
427 rpc.yppasswdd ${nis_yppasswdd_flags}
433 # Start ypbind if we're an NIS client
435 case ${nis_client_enable} in
437 echo -n ' ypbind'; ypbind ${nis_client_flags}
438 case ${nis_ypset_enable} in
440 echo -n ' ypset'; ypset ${nis_ypset_flags}
446 # Start keyserv if we are running Secure RPC
448 case ${keyserv_enable} in
450 echo -n ' keyserv'; keyserv ${keyserv_flags}
454 # Start ypupdated if we are running Secure RPC and we are NIS master
456 case ${rpc_ypupdated_enable} in
458 echo -n ' rpc.ypupdated'; rpc.ypupdated
463 if [ -n "${atm_pass2_done}" ]; then
468 network_pass2_done=YES
472 echo -n 'Starting final network daemons:'
474 case ${nfs_server_enable} in
476 if [ -r /etc/exports ]; then
479 case ${weak_mountd_authentication} in
485 mountd ${mountd_flags}
487 case ${nfs_reserved_port_only} in
489 echo -n ' NFS on reserved port only=YES'
490 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
494 echo -n ' nfsd'; nfsd ${nfs_server_flags}
496 case ${rpc_lockd_enable} in
498 echo -n ' rpc.lockd'; rpc.lockd
502 case ${rpc_statd_enable} in
504 echo -n ' rpc.statd'; rpc.statd
510 case ${single_mountd_enable} in
512 if [ -r /etc/exports ]; then
515 case ${weak_mountd_authentication} in
521 mountd ${mountd_flags}
528 case ${nfs_client_enable} in
530 echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
531 if [ -n "${nfs_access_cache}" ]; then
532 echo -n " NFS access cache time=${nfs_access_cache}"
533 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
539 # If /var/db/mounttab exists, some nfs-server has not been
540 # sucessfully notified about a previous client shutdown.
541 # If there is no /var/db/mounttab, we do nothing.
542 if [ -f /var/db/mounttab ]; then
546 case ${amd_enable} in
549 case ${amd_map_program} in
553 amd_flags="${amd_flags} `eval ${amd_map_program}`"
557 if [ -n "${amd_flags}" ]; then
558 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
565 case ${rwhod_enable} in
567 echo -n ' rwhod'; rwhod ${rwhod_flags}
571 # Kerberos runs ONLY on the Kerberos server machine
572 case ${kerberos_server_enable} in
574 case ${kerberos_stash} in
584 kerberos ${stash_flag} >> /var/log/kerberos.log &
586 case ${kadmind_server_enable} in
589 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
596 case ${pppoed_enable} in
598 if [ -n "${pppoed_provider}" ]; then
599 pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
602 /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
606 case ${sshd_enable} in
608 if [ ! -f /etc/ssh/ssh_host_key ]; then
609 echo ' creating ssh host key';
610 /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
616 network_pass3_done=YES
620 echo -n 'Additional TCP options:'
621 case ${log_in_vain} in
625 echo -n ' log_in_vain=YES'
626 sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
627 sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
632 network_pass4_done=YES