3 # $Id: rc.network,v 1.49 1999/07/08 18:56:02 peter Exp $
4 # From: @(#)netstart 5.9 (Berkeley) 3/30/91
6 # Note that almost all the user-configurable behavior is no longer in
7 # this file, but rather in /etc/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:'
15 # Set the host name if it is not already set
16 if [ -z "`hostname -s`" ] ; then
21 # Set the domainname if we're using NIS
22 if [ -n "$nisdomainname" -a "x$nisdomainname" != "xNO" ] ; then
23 domainname $nisdomainname
28 # Initial ATM interface configuration
29 if [ "X${atm_enable}" = X"YES" -a -f /etc/rc.atm ]; then
34 # ISDN subsystem startup
35 if [ "X${isdn_enable}" = X"YES" -a -f /etc/rc.isdn ]; then
39 # Special options for sppp(4) interfaces go here. These need
40 # to go _before_ the general ifconfig section, since in the case
41 # of hardwired (no link1 flag) but required authentication, you
42 # cannot pass auth parameters down to the already running interface.
43 for ifn in ${sppp_interfaces}; do
44 eval spppcontrol_args=\$spppconfig_${ifn}
45 if [ -n "${spppcontrol_args}" ] ; then
46 # The auth secrets might contain spaces; in order
47 # to retain the quotation, we need to eval them
49 eval spppcontrol ${ifn} ${spppcontrol_args}
53 # Set up all the network interfaces, calling startup scripts if needed
54 if [ "x${network_interfaces}" = "xauto" ]; then
55 network_interfaces="`ifconfig -l`"
57 for ifn in ${network_interfaces}; do
59 if [ -e /etc/start_if.${ifn} ]; then
60 . /etc/start_if.${ifn}
63 # Do the primary ifconfig if specified
64 eval ifconfig_args=\$ifconfig_${ifn}
65 if [ -n "${ifconfig_args}" ] ; then
66 # See if we are using DHCP
67 if [ X"${ifconfig_args}" = X"DHCP" ]; then
68 ${dhcp_program} ${dhcp_flags} ${ifn}
70 ifconfig ${ifn} ${ifconfig_args}
74 # Check to see if aliases need to be added
78 eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
79 if [ -n "${ifconfig_args}" ]; then
80 ifconfig ${ifn} ${ifconfig_args} alias
82 alias=`expr ${alias} + 1`
87 # Do ipx address if specified
88 eval ifconfig_args=\$ifconfig_${ifn}_ipx
89 if [ -n "${ifconfig_args}" ]; then
90 ifconfig ${ifn} ${ifconfig_args}
93 if [ "${showstat}" = "true" ]
99 # Initialize IP filtering using ipfw
101 /sbin/ipfw -q flush > /dev/null 2>&1
108 if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then
109 if kldload ipfw; then
110 firewall_in_kernel=1 # module loaded successfully
111 echo "Kernel firewall module loaded."
113 echo "Warning: firewall kernel module failed to load."
117 # Load the filters if required
118 if [ $firewall_in_kernel = 1 ]; then
119 if [ -z "${firewall_script}" ] ; then
120 firewall_script="/etc/rc.firewall"
122 if [ -f ${firewall_script} -a X"$firewall_enable" = X"YES" ]; then
124 echo -n 'Firewall rules loaded, starting divert daemons:'
126 # Network Address Translation daemon
127 if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then
128 if echo ${natd_interface} | \
129 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
130 natd_ifarg="-a ${natd_interface}"
132 natd_ifarg="-n ${natd_interface}"
134 echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg}
138 IPFW_DEFAULT=`ipfw l 65535`
139 if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then
140 echo -n "Warning: kernel has firewall functionality, "
141 echo "but firewall rules are not enabled."
142 echo " All ip services are disabled."
147 # Additional ATM interface configuration
148 if [ -n "${atm_pass1_done}" ]; then
154 if [ "x$defaultrouter" != "xNO" ] ; then
155 static_routes="default ${static_routes}"
156 route_default="default ${defaultrouter}"
159 # Set up any static routes. This should be done before router discovery.
160 if [ "x${static_routes}" != "x" ]; then
161 for i in ${static_routes}; do
162 eval route_args=\$route_${i}
163 route add ${route_args}
167 echo -n 'Additional routing options:'
168 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then
169 echo -n ' tcp extensions=NO'
170 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
173 if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then
174 echo -n ' log_in_vain=YES'
175 sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
176 sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
179 if [ X"$icmp_bmcastecho" = X"YES" ]; then
180 echo -n ' broadcast ping responses=YES'
181 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
184 if [ "X$gateway_enable" = X"YES" ]; then
185 echo -n ' IP gateway=YES'
186 sysctl -w net.inet.ip.forwarding=1 >/dev/null
189 if [ "X$forward_sourceroute" = X"YES" ]; then
190 echo -n ' do source routing=YES'
191 sysctl -w net.inet.ip.sourceroute=1 >/dev/null
194 if [ "X$accept_sourceroute" = X"YES" ]; then
195 echo -n ' accept source routing=YES'
196 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
199 if [ "X$tcp_keepalive" = X"YES" ]; then
200 echo -n ' TCP keepalive=YES'
201 sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
204 if [ "X$ipxgateway_enable" = X"YES" ]; then
205 echo -n ' IPX gateway=YES'
206 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
209 if [ "X$arpproxy_all" = X"YES" ]; then
210 echo -n ' ARP proxyall=YES'
211 sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
215 echo -n 'routing daemons:'
216 if [ "X$router_enable" = X"YES" ]; then
217 echo -n " ${router}"; ${router} ${router_flags}
220 if [ "X$ipxrouted_enable" = X"YES" ]; then
222 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
225 if [ "X${mrouted_enable}" = X"YES" ]; then
226 echo -n ' mrouted'; mrouted ${mrouted_flags}
229 if [ "X$rarpd_enable" = X"YES" ]; then
230 echo -n ' rarpd'; rarpd ${rarpd_flags}
233 network_pass1_done=YES # Let future generations know we made it.
237 echo -n 'Doing additional network setup:'
238 if [ "X${named_enable}" = X"YES" ]; then
239 echo -n ' named'; ${named_program-"named"} ${named_flags}
242 if [ "X${ntpdate_enable}" = X"YES" ]; then
243 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1
246 if [ "X${xntpd_enable}" = X"YES" ]; then
247 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags}
250 if [ "X${timed_enable}" = X"YES" ]; then
251 echo -n ' timed'; timed ${timed_flags}
254 if [ "X${portmap_enable}" = X"YES" ]; then
255 echo -n ' portmap'; ${portmap_program} ${portmap_flags}
258 # Start ypserv if we're an NIS server.
259 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
260 if [ "X${nis_server_enable}" = X"YES" ]; then
261 echo -n ' ypserv'; ypserv ${nis_server_flags}
263 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then
264 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags}
267 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then
268 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags}
272 # Start ypbind if we're an NIS client
273 if [ "X${nis_client_enable}" = X"YES" ]; then
274 echo -n ' ypbind'; ypbind ${nis_client_flags}
275 if [ "X${nis_ypset_enable}" = X"YES" ]; then
276 echo -n ' ypset'; ypset ${nis_ypset_flags}
280 # Start keyserv if we are running Secure RPC
281 if [ "X${keyserv_enable}" = X"YES" ]; then
282 echo -n ' keyserv'; keyserv ${keyserv_flags}
284 # Start ypupdated if we are running Secure RPC and we are NIS master
285 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then
286 echo -n ' rpc.ypupdated'; rpc.ypupdated
290 if [ -n "${atm_pass2_done}" ]; then
295 network_pass2_done=YES
299 echo -n 'Starting final network daemons:'
301 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then
303 if [ "X${weak_mountd_authentication}" = X"YES" ]; then
306 mountd ${mountd_flags}
307 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
308 echo -n ' NFS on reserved port only=YES'
309 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
311 echo -n ' nfsd'; nfsd ${nfs_server_flags}
312 if [ "X$rpc_lockd_enable" = X"YES" ]; then
313 echo -n ' rpc.lockd'; rpc.lockd
315 if [ "X$rpc_statd_enable" = X"YES" ]; then
316 echo -n ' rpc.statd'; rpc.statd
320 if [ "X${nfs_client_enable}" = X"YES" ]; then
321 echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
322 if [ "X${nfs_access_cache}" != X ]; then
323 echo -n " NFS access cache time=${nfs_access_cache}"
324 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
329 if [ "X${amd_enable}" = X"YES" ]; then
331 if [ "X${amd_map_program}" != X"NO" ]; then
332 amd_flags="${amd_flags} `eval ${amd_map_program}`"
334 if [ -n "$amd_flags" ]
336 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
342 if [ "X${rwhod_enable}" = X"YES" ]; then
343 echo -n ' rwhod'; rwhod ${rwhod_flags}
346 # Kerberos runs ONLY on the Kerberos server machine
347 if [ "X${kerberos_server_enable}" = X"YES" ]; then
348 if [ "X${kerberos_stash}" = "XYES" ]; then
353 echo -n ' kerberos'; \
354 kerberos ${stash_flag} >> /var/log/kerberos.log &
355 if [ "X${kadmind_server_enable}" = "XYES" ]; then
356 echo -n ' kadmind'; \
357 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
363 network_pass3_done=YES