3 # $Id: rc.network,v 1.28 1998/07/08 15:40:53 nectar 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 # Set up all the network interfaces, calling startup scripts if needed
29 for ifn in ${network_interfaces}; do
30 if [ -e /etc/start_if.${ifn} ]; then
31 . /etc/start_if.${ifn}
33 # Do the primary ifconfig if specified
34 eval ifconfig_args=\$ifconfig_${ifn}
35 if [ -n "${ifconfig_args}" ] ; then
36 ifconfig ${ifn} ${ifconfig_args}
38 # Check to see if aliases need to be added
42 eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
43 if [ -n "${ifconfig_args}" ]; then
44 ifconfig ${ifn} ${ifconfig_args} alias
45 alias=`expr ${alias} + 1`
50 # Do ipx address if specified
51 eval ifconfig_args=\$ifconfig_${ifn}_ipx
52 if [ -n "${ifconfig_args}" ]; then
53 ifconfig ${ifn} ${ifconfig_args}
58 # Initialize IP filtering using ipfw
60 /sbin/ipfw -q flush > /dev/null 2>&1
67 if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then
68 if modload /lkm/ipfw_mod.o; then
69 firewall_in_kernel=1 # module loaded successfully
70 echo "Kernel firewall module loaded."
72 echo "Warning: firewall kernel module failed to load."
76 # Load the filters if required
77 if [ $firewall_in_kernel = 1 ]; then
78 if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \
79 "x$firewall_enable" = "xYES" ] ; then
81 echo "Firewall rules loaded."
83 IPFW_DEFAULT=`ipfw l 65535`
84 if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then
85 echo -n "Warning: kernel has firewall functionality, "
86 echo "but firewall rules are not enabled."
87 echo " All ip services are disabled."
94 if [ "x$defaultrouter" != "xNO" ] ; then
95 static_routes="default ${static_routes}"
96 route_default="default ${defaultrouter}"
99 # Set up any static routes. This should be done before router discovery.
100 if [ "x${static_routes}" != "x" ]; then
101 for i in ${static_routes}; do
102 eval route_args=\$route_${i}
103 route add ${route_args}
107 echo -n 'Additional routing options:'
108 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then
109 echo -n ' tcp extensions=NO'
110 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1
111 sysctl -w net.inet.tcp.rfc1644=0 >/dev/null 2>&1
114 if [ "X$gateway_enable" = X"YES" ]; then
115 echo -n ' IP gateway=YES'
116 sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1
119 if [ "X$forward_sourceroute" = X"YES" ]; then
120 echo -n ' do source routing=YES'
121 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1
124 if [ "X$accept_sourceroute" = X"YES" ]; then
125 echo -n ' accept source routing=YES'
126 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1
129 if [ "X$ipxgateway_enable" = X"YES" ]; then
130 echo -n ' IPX gateway=YES'
131 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1
134 if [ "X$arpproxy_all" = X"YES" ]; then
135 echo -n ' enabling ARP_PROXY_ALL: '
136 sysctl -w net.link.ether.inet.proxyall=1 2>&1
140 echo -n 'routing daemons:'
141 if [ "X$router_enable" = X"YES" ]; then
142 echo -n " ${router}"; ${router} ${router_flags}
145 if [ "X$ipxrouted_enable" = X"YES" ]; then
147 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
150 if [ "X${mrouted_enable}" = X"YES" ]; then
151 echo -n ' mrouted'; mrouted ${mrouted_flags}
154 if [ "X$rarpd_enable" = X"YES" ]; then
155 echo -n ' rarpd'; rarpd ${rarpd_flags}
158 network_pass1_done=YES # Let future generations know we made it.
162 echo -n 'Doing additional network setup:'
163 if [ "X${named_enable}" = X"YES" ]; then
164 echo -n ' named'; ${named_program-"named"} ${named_flags}
167 if [ "X${ntpdate_enable}" = X"YES" ]; then
168 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1
171 if [ "X${xntpd_enable}" = X"YES" ]; then
172 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags}
175 if [ "X${timed_enable}" = X"YES" ]; then
176 echo -n ' timed'; timed ${timed_flags}
179 if [ "X${portmap_enable}" = X"YES" ]; then
180 echo -n ' portmap'; portmap ${portmap_flags}
183 # Start ypserv if we're an NIS server.
184 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
185 if [ "X${nis_server_enable}" = X"YES" ]; then
186 echo -n ' ypserv'; ypserv ${nis_server_flags}
188 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then
189 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags}
192 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then
193 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags}
197 # Start ypbind if we're an NIS client
198 if [ "X${nis_client_enable}" = X"YES" ]; then
199 echo -n ' ypbind'; ypbind ${nis_client_flags}
200 if [ "X${nis_ypset_enable}" = X"YES" ]; then
201 echo -n ' ypset'; ypset ${nis_ypset_flags}
205 # Start keyserv if we are running Secure RPC
206 if [ "X${keyserv_enable}" = X"YES" ]; then
207 echo -n ' keyserv'; keyserv ${keyserv_flags}
209 # Start ypupdated if we are running Secure RPC and we are NIS master
210 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then
211 echo -n ' rpc.ypupdated'; rpc.ypupdated
215 network_pass2_done=YES
219 echo -n 'Starting final network daemons:'
221 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then
223 if [ "X${weak_mountd_authentication}" = X"YES" ]; then
226 mountd ${mountd_flags}
227 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
228 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1
230 echo -n ' nfsd'; nfsd ${nfs_server_flags}
231 if [ "X$rpc_lockd_enable" = X"YES" ]; then
232 echo -n ' rpc.lockd'; rpc.lockd
234 if [ "X$rpc_statd_enable" = X"YES" ]; then
235 echo -n ' rpc.statd'; rpc.statd
239 if [ "X${nfs_client_enable}" = X"YES" ]; then
240 echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
243 if [ "X${amd_enable}" = X"YES" ]; then
245 if [ "X${amd_map_program}" != X"NO" ]; then
246 amd_flags="${amd_flags} `${amd_map_program}`"
248 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
251 if [ "X${rwhod_enable}" = X"YES" ]; then
252 echo -n ' rwhod'; rwhod
255 # Kerberos runs ONLY on the Kerberos server machine
256 if [ "X${kerberos_server_enable}" = X"YES" ]; then
257 if [ "X${kerberos_stash}" = "XYES" ]; then
262 echo -n ' kerberos'; \
263 kerberos ${stash_flag} >> /var/log/kerberos.log &
264 if [ "X${kadmind_server_enable}" = "XYES" ]; then
265 echo -n ' kadmind'; \
266 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
271 # Network Address Translation daemon
272 if [ "X${natd_enable}" = X"YES" -a X"${natd_interface}" != X"" \
273 -a X"${firewall_enable}" = X"YES" ]; then
274 if echo ${natd_interface} | \
275 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
276 natd_ifarg="-a ${natd_interface}"
278 natd_ifarg="-n ${natd_interface}"
280 echo -n ' natd'; natd ${natd_flags} ${natd_ifarg}
284 network_pass3_done=YES