3 # $Id: rc.network,v 1.37 1999/01/03 22:19:23 jkh 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 # Set up all the network interfaces, calling startup scripts if needed
40 for ifn in ${network_interfaces}; do
41 if [ -e /etc/start_if.${ifn} ]; then
42 . /etc/start_if.${ifn}
44 # Do the primary ifconfig if specified
45 eval ifconfig_args=\$ifconfig_${ifn}
46 if [ -n "${ifconfig_args}" ] ; then
47 ifconfig ${ifn} ${ifconfig_args}
49 # Check to see if aliases need to be added
53 eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
54 if [ -n "${ifconfig_args}" ]; then
55 ifconfig ${ifn} ${ifconfig_args} alias
56 alias=`expr ${alias} + 1`
61 # Do ipx address if specified
62 eval ifconfig_args=\$ifconfig_${ifn}_ipx
63 if [ -n "${ifconfig_args}" ]; then
64 ifconfig ${ifn} ${ifconfig_args}
69 # Initialize IP filtering using ipfw
71 /sbin/ipfw -q flush > /dev/null 2>&1
78 if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then
80 firewall_in_kernel=1 # module loaded successfully
81 echo "Kernel firewall module loaded."
83 echo "Warning: firewall kernel module failed to load."
87 # Load the filters if required
88 if [ $firewall_in_kernel = 1 ]; then
89 if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \
90 "x$firewall_enable" = "xYES" ] ; then
92 echo "Firewall rules loaded."
94 IPFW_DEFAULT=`ipfw l 65535`
95 if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then
96 echo -n "Warning: kernel has firewall functionality, "
97 echo "but firewall rules are not enabled."
98 echo " All ip services are disabled."
103 # Additional ATM interface configuration
104 if [ -n "${atm_pass1_done}" ]; then
110 if [ "x$defaultrouter" != "xNO" ] ; then
111 static_routes="default ${static_routes}"
112 route_default="default ${defaultrouter}"
115 # Set up any static routes. This should be done before router discovery.
116 if [ "x${static_routes}" != "x" ]; then
117 for i in ${static_routes}; do
118 eval route_args=\$route_${i}
119 route add ${route_args}
123 echo -n 'Additional routing options:'
124 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then
125 echo -n ' tcp extensions=NO'
126 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1
129 if [ X"$icmp_bmcastecho" = X"YES" ]; then
130 echo -n ' broadcast ping responses=YES'
131 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1
134 if [ "X$gateway_enable" = X"YES" ]; then
135 echo -n ' IP gateway=YES'
136 sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1
139 if [ "X$forward_sourceroute" = X"YES" ]; then
140 echo -n ' do source routing=YES'
141 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1
144 if [ "X$accept_sourceroute" = X"YES" ]; then
145 echo -n ' accept source routing=YES'
146 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1
149 if [ "X$ipxgateway_enable" = X"YES" ]; then
150 echo -n ' IPX gateway=YES'
151 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1
154 if [ "X$arpproxy_all" = X"YES" ]; then
155 echo -n ' enabling ARP_PROXY_ALL: '
156 sysctl -w net.link.ether.inet.proxyall=1 2>&1
160 echo -n 'routing daemons:'
161 if [ "X$router_enable" = X"YES" ]; then
162 echo -n " ${router}"; ${router} ${router_flags}
165 if [ "X$ipxrouted_enable" = X"YES" ]; then
167 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
170 if [ "X${mrouted_enable}" = X"YES" ]; then
171 echo -n ' mrouted'; mrouted ${mrouted_flags}
174 if [ "X$rarpd_enable" = X"YES" ]; then
175 echo -n ' rarpd'; rarpd ${rarpd_flags}
178 network_pass1_done=YES # Let future generations know we made it.
182 echo -n 'Doing additional network setup:'
183 if [ "X${named_enable}" = X"YES" ]; then
184 echo -n ' named'; ${named_program-"named"} ${named_flags}
187 if [ "X${ntpdate_enable}" = X"YES" ]; then
188 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1
191 if [ "X${xntpd_enable}" = X"YES" ]; then
192 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags}
195 if [ "X${timed_enable}" = X"YES" ]; then
196 echo -n ' timed'; timed ${timed_flags}
199 if [ "X${portmap_enable}" = X"YES" ]; then
200 echo -n ' portmap'; portmap ${portmap_flags}
203 # Start ypserv if we're an NIS server.
204 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
205 if [ "X${nis_server_enable}" = X"YES" ]; then
206 echo -n ' ypserv'; ypserv ${nis_server_flags}
208 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then
209 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags}
212 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then
213 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags}
217 # Start ypbind if we're an NIS client
218 if [ "X${nis_client_enable}" = X"YES" ]; then
219 echo -n ' ypbind'; ypbind ${nis_client_flags}
220 if [ "X${nis_ypset_enable}" = X"YES" ]; then
221 echo -n ' ypset'; ypset ${nis_ypset_flags}
225 # Start keyserv if we are running Secure RPC
226 if [ "X${keyserv_enable}" = X"YES" ]; then
227 echo -n ' keyserv'; keyserv ${keyserv_flags}
229 # Start ypupdated if we are running Secure RPC and we are NIS master
230 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then
231 echo -n ' rpc.ypupdated'; rpc.ypupdated
235 if [ -n "${atm_pass2_done}" ]; then
240 network_pass2_done=YES
244 echo -n 'Starting final network daemons:'
246 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then
248 if [ "X${weak_mountd_authentication}" = X"YES" ]; then
251 mountd ${mountd_flags}
252 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
253 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1
255 echo -n ' nfsd'; nfsd ${nfs_server_flags}
256 if [ "X$rpc_lockd_enable" = X"YES" ]; then
257 echo -n ' rpc.lockd'; rpc.lockd
259 if [ "X$rpc_statd_enable" = X"YES" ]; then
260 echo -n ' rpc.statd'; rpc.statd
264 if [ "X${nfs_client_enable}" = X"YES" ]; then
265 echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
266 if [ "X${nfs_access_cache}" != X ]; then
267 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
272 if [ "X${amd_enable}" = X"YES" ]; then
274 if [ "X${amd_map_program}" != X"NO" ]; then
275 amd_flags="${amd_flags} `eval ${amd_map_program}`"
277 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
280 if [ "X${rwhod_enable}" = X"YES" ]; then
281 echo -n ' rwhod'; rwhod ${rwhod_flags}
284 # Kerberos runs ONLY on the Kerberos server machine
285 if [ "X${kerberos_server_enable}" = X"YES" ]; then
286 if [ "X${kerberos_stash}" = "XYES" ]; then
291 echo -n ' kerberos'; \
292 kerberos ${stash_flag} >> /var/log/kerberos.log &
293 if [ "X${kadmind_server_enable}" = "XYES" ]; then
294 echo -n ' kadmind'; \
295 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
300 # Network Address Translation daemon
301 if [ "X${natd_enable}" = X"YES" -a X"${natd_interface}" != X"" \
302 -a X"${firewall_enable}" = X"YES" ]; then
303 if echo ${natd_interface} | \
304 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
305 natd_ifarg="-a ${natd_interface}"
307 natd_ifarg="-n ${natd_interface}"
309 echo -n ' natd'; natd ${natd_flags} ${natd_ifarg}
313 network_pass3_done=YES