defaultroute revision 31472
1231057Sdim#!/bin/sh - 2231057Sdim# 3231057Sdim# $Id: rc.network,v 1.12 1997/11/07 20:45:34 sef Exp $ 4231057Sdim# From: @(#)netstart 5.9 (Berkeley) 3/30/91 5231057Sdim 6234982Sdim# Note that almost all the user-configurable behavior is no longer in 7234982Sdim# this file, but rather in /etc/rc.conf. Please check that file 8234353Sdim# first before contemplating any changes here. If you do need to change 9231057Sdim# this file for some reason, we would like to know about it. 10231057Sdim 11231057Sdim# First pass startup stuff. 12 13network_pass1() { 14 echo -n 'Doing initial network setup:' 15 # Set the host name if it is not already set 16 if [ -z "`hostname -s`" ] ; then 17 hostname $hostname 18 echo -n ' hostname' 19 fi 20 21 # Set the domainname if we're using NIS 22 if [ -n "$nisdomainname" -a "x$nisdomainname" != "xNO" ] ; then 23 domainname $nisdomainname 24 echo -n ' domain' 25 fi 26 echo '.' 27 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} ${ifn} 32 fi 33 # Do the primary ifconfig if specified 34 eval ifconfig_args=\$ifconfig_${ifn} 35 if [ -n "${ifconfig_args}" ] ; then 36 ifconfig ${ifn} ${ifconfig_args} 37 fi 38 # Check to see if aliases need to be added 39 alias=0 40 while : 41 do 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` 46 else 47 break; 48 fi 49 done 50 # Do ipx address if specified 51 eval ifconfig_args=\$ifconfig_${ifn}_ipx 52 if [ -n "${ifconfig_args}" ]; then 53 ifconfig ${ifn} ${ifconfig_args} 54 fi 55 ifconfig ${ifn} 56 done 57 58 # Initialize IP filtering using ipfw 59 echo "" 60 /sbin/ipfw -q flush > /dev/null 2>&1 61 if [ $? = 1 ] ; then 62 firewall_in_kernel=0 63 else 64 firewall_in_kernel=1 65 fi 66 67 if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 68 modload /lkm/ipfw_mod.o 69 if [ $? = 0 ]; then 70 firewall_in_kernel=1 # module loaded successfully 71 echo "Kernel firewall module loaded." 72 else 73 echo "Warning: firewall kernel module failed to load." 74 fi 75 fi 76 77 # Load the filters if required 78 if [ $firewall_in_kernel = 1 ]; then 79 if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \ 80 "x$firewall_enable" = "xYES" ] ; then 81 . /etc/rc.firewall 82 echo "Firewall rules loaded." 83 else 84 echo "Warning: kernel has firewall functionality, but firewall rules are not enabled." 85 echo " All ip services are disabled." 86 fi 87 fi 88 89 # Configure routing 90 91 if [ "x$defaultrouter" != "xNO" ] ; then 92 static_routes="default ${static_routes}" 93 route_default="default ${defaultrouter}" 94 fi 95 96 # Set up any static routes. This should be done before router discovery. 97 if [ "x${static_routes}" != "x" ]; then 98 for i in ${static_routes}; do 99 eval route_args=\$route_${i} 100 route add ${route_args} 101 done 102 fi 103 104 echo -n 'Additional routing options:' 105 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 106 echo -n ' tcp extensions=NO' 107 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 108 sysctl -w net.inet.tcp.rfc1644=0 >/dev/null 2>&1 109 fi 110 111 if [ "X$gateway_enable" = X"YES" ]; then 112 echo -n ' IP gateway=YES' 113 sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 114 fi 115 116 if [ "X$router_enable" = X"YES" ]; then 117 echo -n " ${router}"; ${router} ${router_flags} 118 fi 119 120 if [ "X$ipxgateway_enable" = X"YES" ]; then 121 echo -n ' IPX gateway=YES' 122 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 123 fi 124 125 if [ "X$ipxrouted_enable" = X"YES" ]; then 126 echo -n ' IPXrouted: ' 127 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 128 fi 129 130 if [ "X$arpproxy_all" = X"YES" ]; then 131 echo -n ' enabling ARP_PROXY_ALL: ' 132 sysctl -w net.link.ether.inet.proxyall=1 2>&1 133 fi 134 echo '.' 135 network_pass1_done=YES # Let future generations know we made it. 136} 137 138network_pass2() { 139 echo -n 'Doing additional network setup:' 140 if [ "X${named_enable}" = X"YES" ]; then 141 echo -n ' named'; named ${named_flags} 142 fi 143 144 if [ "X${ntpdate_enable}" = X"YES" ]; then 145 echo -n ' ntpdate'; ntpdate ${ntpdate_flags} >/dev/null 2>&1 146 fi 147 148 if [ "X${xntpd_enable}" = X"YES" ]; then 149 echo -n ' xntpd'; xntpd ${xntpd_flags} 150 fi 151 152 if [ "X${timed_enable}" = X"YES" ]; then 153 echo -n ' timed'; timed ${timed_flags} 154 fi 155 156 if [ "X${portmap_enable}" = X"YES" ]; then 157 echo -n ' portmap'; portmap ${portmap_flags} 158 fi 159 160 # Start ypserv if we're an NIS server. 161 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 162 if [ "X${nis_server_enable}" = X"YES" ]; then 163 echo -n ' ypserv'; ypserv ${nis_server_flags} 164 165 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 166 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 167 fi 168 169 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 170 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 171 fi 172 fi 173 174 # Start ypbind if we're an NIS client 175 if [ "X${nis_client_enable}" = X"YES" ]; then 176 echo -n ' ypbind'; ypbind ${nis_client_flags} 177 if [ "X${nis_ypset_enable}" = X"YES" ]; then 178 echo -n ' ypset'; ypset ${nis_ypset_flags} 179 fi 180 fi 181 182 echo '.' 183 network_pass2_done=YES 184} 185 186network_pass3() { 187 echo -n 'Starting final network daemons:' 188 189 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 190 echo -n ' mountd' 191 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 192 mountd_flags="-n" 193 fi 194 mountd ${mountd_flags} 195 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 196 echo -n ' nfsprivport=YES' 197 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 198 fi 199 echo -n ' nfsd'; nfsd ${nfs_server_flags} 200 if [ "X$rpc_lockd_enable" = X"YES" ]; then 201 echo -n ' rpc.lockd'; rpc.lockd 202 fi 203 if [ "X$rpc_statd_enable" = X"YES" ]; then 204 echo -n ' rpc.statd'; rpc.statd 205 fi 206 fi 207 208 if [ "X${nfs_client_enable}" = X"YES" ]; then 209 echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 210 fi 211 212 if [ "X${amd_enable}" = X"YES" ]; then 213 echo -n ' amd' 214 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 215 fi 216 217 if [ "X${rwhod_enable}" = X"YES" ]; then 218 echo -n ' rwhod'; rwhod 219 fi 220 221 # Kerberos runs ONLY on the Kerberos server machine 222 if [ "X${kerberos_server_enable}" = X"YES" ]; then 223 if [ "X${kerberos_stash}" = "XYES" ]; then 224 stash_flag=-n 225 else 226 stash_flag= 227 fi 228 echo -n ' kerberos'; \ 229 kerberos ${stash_flags} >> /var/log/kerberos.log & 230 if [ "X${kadmind_server_enable}" = "XYES" ]; then 231 echo -n ' kadmind'; \ 232 (sleep 20; kadmind ${stash_flags} >/dev/null 2>&1 &) & 233 fi 234 unset stash_flag 235 fi 236 237 # IP multicast routing daemon 238 if [ "X${mrouted_enable}" = X"YES" ]; then 239 echo -n ' mrouted'; mrouted ${mrouted_flags} 240 fi 241 echo '.' 242 network_pass3_done=YES 243} 244