defaultroute revision 44992
1#!/bin/sh - 2# 3# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ 4# From: @(#)netstart 5.9 (Berkeley) 3/30/91 5 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. 10 11# 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 # Initial ATM interface configuration 29 if [ "X${atm_enable}" = X"YES" -a -f /etc/rc.atm ]; then 30 . /etc/rc.atm 31 atm_pass1 32 fi 33 34 # ISDN subsystem startup 35 if [ "X${isdn_enable}" = X"YES" -a -f /etc/rc.isdn ]; then 36 . /etc/rc.isdn 37 fi 38 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 48 # here. 49 eval spppcontrol ${ifn} ${spppcontrol_args} 50 fi 51 done 52 53 # Set up all the network interfaces, calling startup scripts if needed 54 for ifn in ${network_interfaces}; do 55 if [ -e /etc/start_if.${ifn} ]; then 56 . /etc/start_if.${ifn} 57 fi 58 # Do the primary ifconfig if specified 59 eval ifconfig_args=\$ifconfig_${ifn} 60 if [ -n "${ifconfig_args}" ] ; then 61 ifconfig ${ifn} ${ifconfig_args} 62 fi 63 # Check to see if aliases need to be added 64 alias=0 65 while : 66 do 67 eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} 68 if [ -n "${ifconfig_args}" ]; then 69 ifconfig ${ifn} ${ifconfig_args} alias 70 alias=`expr ${alias} + 1` 71 else 72 break; 73 fi 74 done 75 # Do ipx address if specified 76 eval ifconfig_args=\$ifconfig_${ifn}_ipx 77 if [ -n "${ifconfig_args}" ]; then 78 ifconfig ${ifn} ${ifconfig_args} 79 fi 80 ifconfig ${ifn} 81 done 82 83 # Initialize IP filtering using ipfw 84 echo "" 85 /sbin/ipfw -q flush > /dev/null 2>&1 86 if [ $? = 0 ] ; then 87 firewall_in_kernel=1 88 else 89 firewall_in_kernel=0 90 fi 91 92 if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 93 if kldload ipfw; then 94 firewall_in_kernel=1 # module loaded successfully 95 echo "Kernel firewall module loaded." 96 else 97 echo "Warning: firewall kernel module failed to load." 98 fi 99 fi 100 101 # Load the filters if required 102 if [ $firewall_in_kernel = 1 ]; then 103 if [ -f /etc/rc.firewall -a X"$firewall_enable" = X"YES" ]; then 104 . /etc/rc.firewall 105 echo -n 'Firewall rules loaded, starting divert daemons: ' 106 107 # Network Address Translation daemon 108 if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then 109 if echo ${natd_interface} | \ 110 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 111 natd_ifarg="-a ${natd_interface}" 112 else 113 natd_ifarg="-n ${natd_interface}" 114 fi 115 echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 116 fi 117 echo '.' 118 else 119 IPFW_DEFAULT=`ipfw l 65535` 120 if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 121 echo -n "Warning: kernel has firewall functionality, " 122 echo "but firewall rules are not enabled." 123 echo " All ip services are disabled." 124 fi 125 fi 126 fi 127 128 # Additional ATM interface configuration 129 if [ -n "${atm_pass1_done}" ]; then 130 atm_pass2 131 fi 132 133 # Configure routing 134 135 if [ "x$defaultrouter" != "xNO" ] ; then 136 static_routes="default ${static_routes}" 137 route_default="default ${defaultrouter}" 138 fi 139 140 # Set up any static routes. This should be done before router discovery. 141 if [ "x${static_routes}" != "x" ]; then 142 for i in ${static_routes}; do 143 eval route_args=\$route_${i} 144 route add ${route_args} 145 done 146 fi 147 148 echo -n 'Additional routing options:' 149 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 150 echo -n ' tcp extensions=NO' 151 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 152 fi 153 154 if [ X"$icmp_bmcastecho" = X"YES" ]; then 155 echo -n ' broadcast ping responses=YES' 156 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 157 fi 158 159 if [ "X$gateway_enable" = X"YES" ]; then 160 echo -n ' IP gateway=YES' 161 sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 162 fi 163 164 if [ "X$forward_sourceroute" = X"YES" ]; then 165 echo -n ' do source routing=YES' 166 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 167 fi 168 169 if [ "X$accept_sourceroute" = X"YES" ]; then 170 echo -n ' accept source routing=YES' 171 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 172 fi 173 174 if [ "X$ipxgateway_enable" = X"YES" ]; then 175 echo -n ' IPX gateway=YES' 176 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 177 fi 178 179 if [ "X$arpproxy_all" = X"YES" ]; then 180 echo -n ' enabling ARP_PROXY_ALL: ' 181 sysctl -w net.link.ether.inet.proxyall=1 2>&1 182 fi 183 echo '.' 184 185 echo -n 'routing daemons:' 186 if [ "X$router_enable" = X"YES" ]; then 187 echo -n " ${router}"; ${router} ${router_flags} 188 fi 189 190 if [ "X$ipxrouted_enable" = X"YES" ]; then 191 echo -n ' IPXrouted' 192 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 193 fi 194 195 if [ "X${mrouted_enable}" = X"YES" ]; then 196 echo -n ' mrouted'; mrouted ${mrouted_flags} 197 fi 198 199 if [ "X$rarpd_enable" = X"YES" ]; then 200 echo -n ' rarpd'; rarpd ${rarpd_flags} 201 fi 202 echo '.' 203 network_pass1_done=YES # Let future generations know we made it. 204} 205 206network_pass2() { 207 echo -n 'Doing additional network setup:' 208 if [ "X${named_enable}" = X"YES" ]; then 209 echo -n ' named'; ${named_program-"named"} ${named_flags} 210 fi 211 212 if [ "X${ntpdate_enable}" = X"YES" ]; then 213 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 214 fi 215 216 if [ "X${xntpd_enable}" = X"YES" ]; then 217 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 218 fi 219 220 if [ "X${timed_enable}" = X"YES" ]; then 221 echo -n ' timed'; timed ${timed_flags} 222 fi 223 224 if [ "X${portmap_enable}" = X"YES" ]; then 225 echo -n ' portmap'; ${portmap_program} ${portmap_flags} 226 fi 227 228 # Start ypserv if we're an NIS server. 229 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 230 if [ "X${nis_server_enable}" = X"YES" ]; then 231 echo -n ' ypserv'; ypserv ${nis_server_flags} 232 233 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 234 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 235 fi 236 237 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 238 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 239 fi 240 fi 241 242 # Start ypbind if we're an NIS client 243 if [ "X${nis_client_enable}" = X"YES" ]; then 244 echo -n ' ypbind'; ypbind ${nis_client_flags} 245 if [ "X${nis_ypset_enable}" = X"YES" ]; then 246 echo -n ' ypset'; ypset ${nis_ypset_flags} 247 fi 248 fi 249 250 # Start keyserv if we are running Secure RPC 251 if [ "X${keyserv_enable}" = X"YES" ]; then 252 echo -n ' keyserv'; keyserv ${keyserv_flags} 253 fi 254 # Start ypupdated if we are running Secure RPC and we are NIS master 255 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 256 echo -n ' rpc.ypupdated'; rpc.ypupdated 257 fi 258 259 # Start ATM daemons 260 if [ -n "${atm_pass2_done}" ]; then 261 atm_pass3 262 fi 263 264 echo '.' 265 network_pass2_done=YES 266} 267 268network_pass3() { 269 echo -n 'Starting final network daemons:' 270 271 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 272 echo -n ' mountd' 273 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 274 mountd_flags="-n" 275 fi 276 mountd ${mountd_flags} 277 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 278 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 279 fi 280 echo -n ' nfsd'; nfsd ${nfs_server_flags} 281 if [ "X$rpc_lockd_enable" = X"YES" ]; then 282 echo -n ' rpc.lockd'; rpc.lockd 283 fi 284 if [ "X$rpc_statd_enable" = X"YES" ]; then 285 echo -n ' rpc.statd'; rpc.statd 286 fi 287 fi 288 289 if [ "X${nfs_client_enable}" = X"YES" ]; then 290 echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 291 if [ "X${nfs_access_cache}" != X ]; then 292 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 293 >/dev/null 2>&1 294 fi 295 fi 296 297 if [ "X${amd_enable}" = X"YES" ]; then 298 echo -n ' amd' 299 if [ "X${amd_map_program}" != X"NO" ]; then 300 amd_flags="${amd_flags} `eval ${amd_map_program}`" 301 fi 302 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 303 fi 304 305 if [ "X${rwhod_enable}" = X"YES" ]; then 306 echo -n ' rwhod'; rwhod ${rwhod_flags} 307 fi 308 309 # Kerberos runs ONLY on the Kerberos server machine 310 if [ "X${kerberos_server_enable}" = X"YES" ]; then 311 if [ "X${kerberos_stash}" = "XYES" ]; then 312 stash_flag=-n 313 else 314 stash_flag= 315 fi 316 echo -n ' kerberos'; \ 317 kerberos ${stash_flag} >> /var/log/kerberos.log & 318 if [ "X${kadmind_server_enable}" = "XYES" ]; then 319 echo -n ' kadmind'; \ 320 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 321 fi 322 unset stash_flag 323 fi 324 325 echo '.' 326 network_pass3_done=YES 327} 328