3 # $Id: rc.network,v 1.29 1998/08/14 06:55:17 phk 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
113 if [ "X$gateway_enable" = X"YES" ]; then
114 echo -n ' IP gateway=YES'
115 sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1
118 if [ "X$forward_sourceroute" = X"YES" ]; then
119 echo -n ' do source routing=YES'
120 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1
123 if [ "X$accept_sourceroute" = X"YES" ]; then
124 echo -n ' accept source routing=YES'
125 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1
128 if [ "X$ipxgateway_enable" = X"YES" ]; then
129 echo -n ' IPX gateway=YES'
130 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1
133 if [ "X$arpproxy_all" = X"YES" ]; then
134 echo -n ' enabling ARP_PROXY_ALL: '
135 sysctl -w net.link.ether.inet.proxyall=1 2>&1
139 echo -n 'routing daemons:'
140 if [ "X$router_enable" = X"YES" ]; then
141 echo -n " ${router}"; ${router} ${router_flags}
144 if [ "X$ipxrouted_enable" = X"YES" ]; then
146 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
149 if [ "X${mrouted_enable}" = X"YES" ]; then
150 echo -n ' mrouted'; mrouted ${mrouted_flags}
153 if [ "X$rarpd_enable" = X"YES" ]; then
154 echo -n ' rarpd'; rarpd ${rarpd_flags}
157 network_pass1_done=YES # Let future generations know we made it.
161 echo -n 'Doing additional network setup:'
162 if [ "X${named_enable}" = X"YES" ]; then
163 echo -n ' named'; ${named_program-"named"} ${named_flags}
166 if [ "X${ntpdate_enable}" = X"YES" ]; then
167 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1
170 if [ "X${xntpd_enable}" = X"YES" ]; then
171 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags}
174 if [ "X${timed_enable}" = X"YES" ]; then
175 echo -n ' timed'; timed ${timed_flags}
178 if [ "X${portmap_enable}" = X"YES" ]; then
179 echo -n ' portmap'; portmap ${portmap_flags}
182 # Start ypserv if we're an NIS server.
183 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
184 if [ "X${nis_server_enable}" = X"YES" ]; then
185 echo -n ' ypserv'; ypserv ${nis_server_flags}
187 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then
188 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags}
191 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then
192 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags}
196 # Start ypbind if we're an NIS client
197 if [ "X${nis_client_enable}" = X"YES" ]; then
198 echo -n ' ypbind'; ypbind ${nis_client_flags}
199 if [ "X${nis_ypset_enable}" = X"YES" ]; then
200 echo -n ' ypset'; ypset ${nis_ypset_flags}
204 # Start keyserv if we are running Secure RPC
205 if [ "X${keyserv_enable}" = X"YES" ]; then
206 echo -n ' keyserv'; keyserv ${keyserv_flags}
208 # Start ypupdated if we are running Secure RPC and we are NIS master
209 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then
210 echo -n ' rpc.ypupdated'; rpc.ypupdated
214 network_pass2_done=YES
218 echo -n 'Starting final network daemons:'
220 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then
222 if [ "X${weak_mountd_authentication}" = X"YES" ]; then
225 mountd ${mountd_flags}
226 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
227 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1
229 echo -n ' nfsd'; nfsd ${nfs_server_flags}
230 if [ "X$rpc_lockd_enable" = X"YES" ]; then
231 echo -n ' rpc.lockd'; rpc.lockd
233 if [ "X$rpc_statd_enable" = X"YES" ]; then
234 echo -n ' rpc.statd'; rpc.statd
238 if [ "X${nfs_client_enable}" = X"YES" ]; then
239 echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
242 if [ "X${amd_enable}" = X"YES" ]; then
244 if [ "X${amd_map_program}" != X"NO" ]; then
245 amd_flags="${amd_flags} `${amd_map_program}`"
247 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
250 if [ "X${rwhod_enable}" = X"YES" ]; then
251 echo -n ' rwhod'; rwhod
254 # Kerberos runs ONLY on the Kerberos server machine
255 if [ "X${kerberos_server_enable}" = X"YES" ]; then
256 if [ "X${kerberos_stash}" = "XYES" ]; then
261 echo -n ' kerberos'; \
262 kerberos ${stash_flag} >> /var/log/kerberos.log &
263 if [ "X${kadmind_server_enable}" = "XYES" ]; then
264 echo -n ' kadmind'; \
265 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
270 # Network Address Translation daemon
271 if [ "X${natd_enable}" = X"YES" -a X"${natd_interface}" != X"" \
272 -a X"${firewall_enable}" = X"YES" ]; then
273 if echo ${natd_interface} | \
274 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
275 natd_ifarg="-a ${natd_interface}"
277 natd_ifarg="-n ${natd_interface}"
279 echo -n ' natd'; natd ${natd_flags} ${natd_ifarg}
283 network_pass3_done=YES