defaultroute revision 45542
125184Sjkh#!/bin/sh - 225184Sjkh# 345542Sdes# $Id: rc.network,v 1.42 1999/03/28 20:36:03 imp Exp $ 425184Sjkh# From: @(#)netstart 5.9 (Berkeley) 3/30/91 525184Sjkh 625184Sjkh# Note that almost all the user-configurable behavior is no longer in 725184Sjkh# this file, but rather in /etc/rc.conf. Please check that file 825184Sjkh# first before contemplating any changes here. If you do need to change 925184Sjkh# this file for some reason, we would like to know about it. 1025184Sjkh 1125184Sjkh# First pass startup stuff. 1225184Sjkh 1325184Sjkhnetwork_pass1() { 1425184Sjkh echo -n 'Doing initial network setup:' 1525184Sjkh # Set the host name if it is not already set 1625184Sjkh if [ -z "`hostname -s`" ] ; then 1725184Sjkh hostname $hostname 1825184Sjkh echo -n ' hostname' 1925184Sjkh fi 2025184Sjkh 2125184Sjkh # Set the domainname if we're using NIS 2225184Sjkh if [ -n "$nisdomainname" -a "x$nisdomainname" != "xNO" ] ; then 2325184Sjkh domainname $nisdomainname 2425184Sjkh echo -n ' domain' 2525184Sjkh fi 2625184Sjkh echo '.' 2725184Sjkh 2840006Sphk # Initial ATM interface configuration 2940006Sphk if [ "X${atm_enable}" = X"YES" -a -f /etc/rc.atm ]; then 3040006Sphk . /etc/rc.atm 3140006Sphk atm_pass1 3240006Sphk fi 3340006Sphk 3442621Shm # ISDN subsystem startup 3542621Shm if [ "X${isdn_enable}" = X"YES" -a -f /etc/rc.isdn ]; then 3642621Shm . /etc/rc.isdn 3742621Shm fi 3842621Shm 3942627Sjoerg # Special options for sppp(4) interfaces go here. These need 4042627Sjoerg # to go _before_ the general ifconfig section, since in the case 4142627Sjoerg # of hardwired (no link1 flag) but required authentication, you 4242627Sjoerg # cannot pass auth parameters down to the already running interface. 4342627Sjoerg for ifn in ${sppp_interfaces}; do 4442627Sjoerg eval spppcontrol_args=\$spppconfig_${ifn} 4542627Sjoerg if [ -n "${spppcontrol_args}" ] ; then 4642627Sjoerg # The auth secrets might contain spaces; in order 4742627Sjoerg # to retain the quotation, we need to eval them 4842627Sjoerg # here. 4942627Sjoerg eval spppcontrol ${ifn} ${spppcontrol_args} 5042627Sjoerg fi 5142627Sjoerg done 5242627Sjoerg 5325184Sjkh # Set up all the network interfaces, calling startup scripts if needed 5425184Sjkh for ifn in ${network_interfaces}; do 5525184Sjkh if [ -e /etc/start_if.${ifn} ]; then 5633682Sbrian . /etc/start_if.${ifn} 5725184Sjkh fi 5825184Sjkh # Do the primary ifconfig if specified 5925184Sjkh eval ifconfig_args=\$ifconfig_${ifn} 6025184Sjkh if [ -n "${ifconfig_args}" ] ; then 6125184Sjkh ifconfig ${ifn} ${ifconfig_args} 6225184Sjkh fi 6325184Sjkh # Check to see if aliases need to be added 6425184Sjkh alias=0 6525184Sjkh while : 6625184Sjkh do 6725184Sjkh eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} 6825184Sjkh if [ -n "${ifconfig_args}" ]; then 6925184Sjkh ifconfig ${ifn} ${ifconfig_args} alias 7025184Sjkh alias=`expr ${alias} + 1` 7125184Sjkh else 7225184Sjkh break; 7325184Sjkh fi 7425184Sjkh done 7525184Sjkh # Do ipx address if specified 7625184Sjkh eval ifconfig_args=\$ifconfig_${ifn}_ipx 7725184Sjkh if [ -n "${ifconfig_args}" ]; then 7825184Sjkh ifconfig ${ifn} ${ifconfig_args} 7925184Sjkh fi 8025184Sjkh ifconfig ${ifn} 8125184Sjkh done 8229300Sdanny 8329300Sdanny # Initialize IP filtering using ipfw 8429300Sdanny echo "" 8529300Sdanny /sbin/ipfw -q flush > /dev/null 2>&1 8632382Salex if [ $? = 0 ] ; then 8732382Salex firewall_in_kernel=1 8832382Salex else 8929300Sdanny firewall_in_kernel=0 9029300Sdanny fi 9129300Sdanny 9229300Sdanny if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 9341077Speter if kldload ipfw; then 9429300Sdanny firewall_in_kernel=1 # module loaded successfully 9529300Sdanny echo "Kernel firewall module loaded." 9629300Sdanny else 9729300Sdanny echo "Warning: firewall kernel module failed to load." 9829300Sdanny fi 9929300Sdanny fi 10029300Sdanny 10129300Sdanny # Load the filters if required 10229300Sdanny if [ $firewall_in_kernel = 1 ]; then 10345542Sdes if [ -z "${firewall_script}" ] ; then 10445542Sdes firewall_script="/etc/rc.firewall" 10545542Sdes fi 10645542Sdes if [ -f ${firewall_script} -a X"$firewall_enable" = X"YES" ]; then 10745542Sdes . ${firewall_script} 10844992Sbrian echo -n 'Firewall rules loaded, starting divert daemons: ' 10944992Sbrian 11044992Sbrian # Network Address Translation daemon 11144992Sbrian if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then 11244992Sbrian if echo ${natd_interface} | \ 11344992Sbrian grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 11444992Sbrian natd_ifarg="-a ${natd_interface}" 11544992Sbrian else 11644992Sbrian natd_ifarg="-n ${natd_interface}" 11744992Sbrian fi 11844992Sbrian echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 11944992Sbrian fi 12044992Sbrian echo '.' 12129300Sdanny else 12233337Salex IPFW_DEFAULT=`ipfw l 65535` 12333337Salex if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 12433149Salex echo -n "Warning: kernel has firewall functionality, " 12533149Salex echo "but firewall rules are not enabled." 12633149Salex echo " All ip services are disabled." 12733149Salex fi 12829300Sdanny fi 12925184Sjkh fi 13025184Sjkh 13140006Sphk # Additional ATM interface configuration 13240006Sphk if [ -n "${atm_pass1_done}" ]; then 13340006Sphk atm_pass2 13440006Sphk fi 13540006Sphk 13629300Sdanny # Configure routing 13729300Sdanny 13825184Sjkh if [ "x$defaultrouter" != "xNO" ] ; then 13925184Sjkh static_routes="default ${static_routes}" 14025184Sjkh route_default="default ${defaultrouter}" 14125184Sjkh fi 14225184Sjkh 14325184Sjkh # Set up any static routes. This should be done before router discovery. 14425184Sjkh if [ "x${static_routes}" != "x" ]; then 14525184Sjkh for i in ${static_routes}; do 14625184Sjkh eval route_args=\$route_${i} 14725184Sjkh route add ${route_args} 14825184Sjkh done 14925184Sjkh fi 15025184Sjkh 15125184Sjkh echo -n 'Additional routing options:' 15227218Spst if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 15327218Spst echo -n ' tcp extensions=NO' 15427218Spst sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 15527218Spst fi 15627218Spst 15745096Simp if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then 15845096Simp echo -n ' log_in_vain=YES' 15945096Simp sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 16045096Simp sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 16145096Simp fi 16245096Simp 16339267Sjkoshy if [ X"$icmp_bmcastecho" = X"YES" ]; then 16439267Sjkoshy echo -n ' broadcast ping responses=YES' 16539267Sjkoshy sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 16639267Sjkoshy fi 16739267Sjkoshy 16825184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 16925365Sjkh echo -n ' IP gateway=YES' 17025184Sjkh sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 17125184Sjkh fi 17225184Sjkh 17333439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 17433439Sguido echo -n ' do source routing=YES' 17533439Sguido sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 17633439Sguido fi 17733439Sguido 17833439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 17933439Sguido echo -n ' accept source routing=YES' 18033439Sguido sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 18133439Sguido fi 18233439Sguido 18325184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 18425365Sjkh echo -n ' IPX gateway=YES' 18525184Sjkh sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 18625184Sjkh fi 18725184Sjkh 18836174Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 18936174Sjkh echo -n ' enabling ARP_PROXY_ALL: ' 19036174Sjkh sysctl -w net.link.ether.inet.proxyall=1 2>&1 19136174Sjkh fi 19236174Sjkh echo '.' 19336174Sjkh 19436174Sjkh echo -n 'routing daemons:' 19536174Sjkh if [ "X$router_enable" = X"YES" ]; then 19636174Sjkh echo -n " ${router}"; ${router} ${router_flags} 19736174Sjkh fi 19836174Sjkh 19925184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 20036174Sjkh echo -n ' IPXrouted' 20125184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 20225184Sjkh fi 20325765Sjkh 20436174Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 20536174Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 20625765Sjkh fi 20736174Sjkh 20834395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 20934395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 21034395Sjkh fi 21125184Sjkh echo '.' 21225184Sjkh network_pass1_done=YES # Let future generations know we made it. 21325184Sjkh} 21425184Sjkh 21525184Sjkhnetwork_pass2() { 21625184Sjkh echo -n 'Doing additional network setup:' 21725184Sjkh if [ "X${named_enable}" = X"YES" ]; then 21832949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 21925184Sjkh fi 22025184Sjkh 22131472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 22235787Sandreas echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 22331472Sobrien fi 22425184Sjkh 22531472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 22635787Sandreas echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 22725184Sjkh fi 22825184Sjkh 22925184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 23025184Sjkh echo -n ' timed'; timed ${timed_flags} 23125184Sjkh fi 23225184Sjkh 23325184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 23444668Sjfitz echo -n ' portmap'; ${portmap_program} ${portmap_flags} 23525184Sjkh fi 23625184Sjkh 23725184Sjkh # Start ypserv if we're an NIS server. 23825184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 23925184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 24025184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 24125184Sjkh 24225184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 24325184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 24425184Sjkh fi 24525184Sjkh 24625184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 24725184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 24825184Sjkh fi 24925184Sjkh fi 25025184Sjkh 25125184Sjkh # Start ypbind if we're an NIS client 25225184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 25325184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 25425184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 25525184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 25625184Sjkh fi 25725184Sjkh fi 25825184Sjkh 25935149Smarkm # Start keyserv if we are running Secure RPC 26035149Smarkm if [ "X${keyserv_enable}" = X"YES" ]; then 26135149Smarkm echo -n ' keyserv'; keyserv ${keyserv_flags} 26235149Smarkm fi 26335149Smarkm # Start ypupdated if we are running Secure RPC and we are NIS master 26435149Smarkm if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 26535149Smarkm echo -n ' rpc.ypupdated'; rpc.ypupdated 26635149Smarkm fi 26735149Smarkm 26840006Sphk # Start ATM daemons 26940006Sphk if [ -n "${atm_pass2_done}" ]; then 27040006Sphk atm_pass3 27140006Sphk fi 27240006Sphk 27325184Sjkh echo '.' 27425184Sjkh network_pass2_done=YES 27525184Sjkh} 27625184Sjkh 27725184Sjkhnetwork_pass3() { 27825184Sjkh echo -n 'Starting final network daemons:' 27925184Sjkh 28025184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 28125184Sjkh echo -n ' mountd' 28225184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 28325184Sjkh mountd_flags="-n" 28425184Sjkh fi 28525184Sjkh mountd ${mountd_flags} 28625184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 28725184Sjkh sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 28825184Sjkh fi 28925916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 29025184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 29125184Sjkh echo -n ' rpc.lockd'; rpc.lockd 29225184Sjkh fi 29325184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 29425184Sjkh echo -n ' rpc.statd'; rpc.statd 29525184Sjkh fi 29625184Sjkh fi 29725184Sjkh 29825184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 29925916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 30041371Sjkoshy if [ "X${nfs_access_cache}" != X ]; then 30141371Sjkoshy sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 30241371Sjkoshy >/dev/null 2>&1 30341185Smsmith fi 30425184Sjkh fi 30525184Sjkh 30625184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 30725184Sjkh echo -n ' amd' 30835459Sphk if [ "X${amd_map_program}" != X"NO" ]; then 30939380Scracauer amd_flags="${amd_flags} `eval ${amd_map_program}`" 31035459Sphk fi 31125184Sjkh amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 31225184Sjkh fi 31325184Sjkh 31425184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 31542270Sjkh echo -n ' rwhod'; rwhod ${rwhod_flags} 31625184Sjkh fi 31725184Sjkh 31825184Sjkh # Kerberos runs ONLY on the Kerberos server machine 31925184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 32031033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 32131033Ssef stash_flag=-n 32231033Ssef else 32331033Ssef stash_flag= 32431033Ssef fi 32531033Ssef echo -n ' kerberos'; \ 32638316Sphk kerberos ${stash_flag} >> /var/log/kerberos.log & 32731033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 32831033Ssef echo -n ' kadmind'; \ 32938316Sphk (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 33031033Ssef fi 33131033Ssef unset stash_flag 33225184Sjkh fi 33325184Sjkh 33425184Sjkh echo '.' 33525184Sjkh network_pass3_done=YES 33625184Sjkh} 337