defaultroute revision 47838
1#!/bin/sh - 2# 3# $Id: rc.network,v 1.46 1999/06/05 12:06:19 bde 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 [ -z "${firewall_script}" ] ; then 104 firewall_script="/etc/rc.firewall" 105 fi 106 if [ -f ${firewall_script} -a X"$firewall_enable" = X"YES" ]; then 107 . ${firewall_script} 108 echo -n 'Firewall rules loaded, starting divert daemons:' 109 110 # Network Address Translation daemon 111 if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then 112 if echo ${natd_interface} | \ 113 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 114 natd_ifarg="-a ${natd_interface}" 115 else 116 natd_ifarg="-n ${natd_interface}" 117 fi 118 echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 119 fi 120 echo '.' 121 else 122 IPFW_DEFAULT=`ipfw l 65535` 123 if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 124 echo -n "Warning: kernel has firewall functionality, " 125 echo "but firewall rules are not enabled." 126 echo " All ip services are disabled." 127 fi 128 fi 129 fi 130 131 # Additional ATM interface configuration 132 if [ -n "${atm_pass1_done}" ]; then 133 atm_pass2 134 fi 135 136 # Configure routing 137 138 if [ "x$defaultrouter" != "xNO" ] ; then 139 static_routes="default ${static_routes}" 140 route_default="default ${defaultrouter}" 141 fi 142 143 # Set up any static routes. This should be done before router discovery. 144 if [ "x${static_routes}" != "x" ]; then 145 for i in ${static_routes}; do 146 eval route_args=\$route_${i} 147 route add ${route_args} 148 done 149 fi 150 151 echo -n 'Additional routing options:' 152 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 153 echo -n ' tcp extensions=NO' 154 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 155 fi 156 157 if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then 158 echo -n ' log_in_vain=YES' 159 sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 160 sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 161 fi 162 163 if [ X"$icmp_bmcastecho" = X"YES" ]; then 164 echo -n ' broadcast ping responses=YES' 165 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 166 fi 167 168 if [ "X$gateway_enable" = X"YES" ]; then 169 echo -n ' IP gateway=YES' 170 sysctl -w net.inet.ip.forwarding=1 >/dev/null 171 fi 172 173 if [ "X$forward_sourceroute" = X"YES" ]; then 174 echo -n ' do source routing=YES' 175 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 176 fi 177 178 if [ "X$accept_sourceroute" = X"YES" ]; then 179 echo -n ' accept source routing=YES' 180 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 181 fi 182 183 if [ "X$tcp_keepalive" = X"YES" ]; then 184 echo -n ' TCP keepalive=YES' 185 sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null 186 fi 187 188 if [ "X$ipxgateway_enable" = X"YES" ]; then 189 echo -n ' IPX gateway=YES' 190 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 191 fi 192 193 if [ "X$arpproxy_all" = X"YES" ]; then 194 echo -n ' ARP proxyall=YES' 195 sysctl -w net.link.ether.inet.proxyall=1 >/dev/null 196 fi 197 echo '.' 198 199 echo -n 'routing daemons:' 200 if [ "X$router_enable" = X"YES" ]; then 201 echo -n " ${router}"; ${router} ${router_flags} 202 fi 203 204 if [ "X$ipxrouted_enable" = X"YES" ]; then 205 echo -n ' IPXrouted' 206 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 207 fi 208 209 if [ "X${mrouted_enable}" = X"YES" ]; then 210 echo -n ' mrouted'; mrouted ${mrouted_flags} 211 fi 212 213 if [ "X$rarpd_enable" = X"YES" ]; then 214 echo -n ' rarpd'; rarpd ${rarpd_flags} 215 fi 216 echo '.' 217 network_pass1_done=YES # Let future generations know we made it. 218} 219 220network_pass2() { 221 echo -n 'Doing additional network setup:' 222 if [ "X${named_enable}" = X"YES" ]; then 223 echo -n ' named'; ${named_program-"named"} ${named_flags} 224 fi 225 226 if [ "X${ntpdate_enable}" = X"YES" ]; then 227 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 228 fi 229 230 if [ "X${xntpd_enable}" = X"YES" ]; then 231 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 232 fi 233 234 if [ "X${timed_enable}" = X"YES" ]; then 235 echo -n ' timed'; timed ${timed_flags} 236 fi 237 238 if [ "X${portmap_enable}" = X"YES" ]; then 239 echo -n ' portmap'; ${portmap_program} ${portmap_flags} 240 fi 241 242 # Start ypserv if we're an NIS server. 243 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 244 if [ "X${nis_server_enable}" = X"YES" ]; then 245 echo -n ' ypserv'; ypserv ${nis_server_flags} 246 247 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 248 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 249 fi 250 251 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 252 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 253 fi 254 fi 255 256 # Start ypbind if we're an NIS client 257 if [ "X${nis_client_enable}" = X"YES" ]; then 258 echo -n ' ypbind'; ypbind ${nis_client_flags} 259 if [ "X${nis_ypset_enable}" = X"YES" ]; then 260 echo -n ' ypset'; ypset ${nis_ypset_flags} 261 fi 262 fi 263 264 # Start keyserv if we are running Secure RPC 265 if [ "X${keyserv_enable}" = X"YES" ]; then 266 echo -n ' keyserv'; keyserv ${keyserv_flags} 267 fi 268 # Start ypupdated if we are running Secure RPC and we are NIS master 269 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 270 echo -n ' rpc.ypupdated'; rpc.ypupdated 271 fi 272 273 # Start ATM daemons 274 if [ -n "${atm_pass2_done}" ]; then 275 atm_pass3 276 fi 277 278 echo '.' 279 network_pass2_done=YES 280} 281 282network_pass3() { 283 echo -n 'Starting final network daemons:' 284 285 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 286 echo -n ' mountd' 287 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 288 mountd_flags="-n" 289 fi 290 mountd ${mountd_flags} 291 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 292 echo -n ' NFS on reserved port only=YES' 293 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 294 fi 295 echo -n ' nfsd'; nfsd ${nfs_server_flags} 296 if [ "X$rpc_lockd_enable" = X"YES" ]; then 297 echo -n ' rpc.lockd'; rpc.lockd 298 fi 299 if [ "X$rpc_statd_enable" = X"YES" ]; then 300 echo -n ' rpc.statd'; rpc.statd 301 fi 302 fi 303 304 if [ "X${nfs_client_enable}" = X"YES" ]; then 305 echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 306 if [ "X${nfs_access_cache}" != X ]; then 307 echo -n " NFS access cache time=${nfs_access_cache}" 308 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 309 >/dev/null 310 fi 311 fi 312 313 if [ "X${amd_enable}" = X"YES" ]; then 314 echo -n ' amd' 315 if [ "X${amd_map_program}" != X"NO" ]; then 316 amd_flags="${amd_flags} `eval ${amd_map_program}`" 317 fi 318 if [ -n "$amd_flags" ] 319 then 320 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 321 else 322 amd 2> /dev/null 323 fi 324 fi 325 326 if [ "X${rwhod_enable}" = X"YES" ]; then 327 echo -n ' rwhod'; rwhod ${rwhod_flags} 328 fi 329 330 # Kerberos runs ONLY on the Kerberos server machine 331 if [ "X${kerberos_server_enable}" = X"YES" ]; then 332 if [ "X${kerberos_stash}" = "XYES" ]; then 333 stash_flag=-n 334 else 335 stash_flag= 336 fi 337 echo -n ' kerberos'; \ 338 kerberos ${stash_flag} >> /var/log/kerberos.log & 339 if [ "X${kadmind_server_enable}" = "XYES" ]; then 340 echo -n ' kadmind'; \ 341 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 342 fi 343 unset stash_flag 344 fi 345 346 echo '.' 347 network_pass3_done=YES 348} 349