routing revision 45096
125184Sjkh#!/bin/sh - 225184Sjkh# 345096Simp# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian 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 10344992Sbrian if [ -f /etc/rc.firewall -a X"$firewall_enable" = X"YES" ]; then 10425364Sjkh . /etc/rc.firewall 10544992Sbrian echo -n 'Firewall rules loaded, starting divert daemons: ' 10644992Sbrian 10744992Sbrian # Network Address Translation daemon 10844992Sbrian if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then 10944992Sbrian if echo ${natd_interface} | \ 11044992Sbrian grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 11144992Sbrian natd_ifarg="-a ${natd_interface}" 11244992Sbrian else 11344992Sbrian natd_ifarg="-n ${natd_interface}" 11444992Sbrian fi 11544992Sbrian echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 11644992Sbrian fi 11744992Sbrian echo '.' 11829300Sdanny else 11933337Salex IPFW_DEFAULT=`ipfw l 65535` 12033337Salex if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 12133149Salex echo -n "Warning: kernel has firewall functionality, " 12233149Salex echo "but firewall rules are not enabled." 12333149Salex echo " All ip services are disabled." 12433149Salex fi 12529300Sdanny fi 12625184Sjkh fi 12725184Sjkh 12840006Sphk # Additional ATM interface configuration 12940006Sphk if [ -n "${atm_pass1_done}" ]; then 13040006Sphk atm_pass2 13140006Sphk fi 13240006Sphk 13329300Sdanny # Configure routing 13429300Sdanny 13525184Sjkh if [ "x$defaultrouter" != "xNO" ] ; then 13625184Sjkh static_routes="default ${static_routes}" 13725184Sjkh route_default="default ${defaultrouter}" 13825184Sjkh fi 13925184Sjkh 14025184Sjkh # Set up any static routes. This should be done before router discovery. 14125184Sjkh if [ "x${static_routes}" != "x" ]; then 14225184Sjkh for i in ${static_routes}; do 14325184Sjkh eval route_args=\$route_${i} 14425184Sjkh route add ${route_args} 14525184Sjkh done 14625184Sjkh fi 14725184Sjkh 14825184Sjkh echo -n 'Additional routing options:' 14927218Spst if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 15027218Spst echo -n ' tcp extensions=NO' 15127218Spst sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 15227218Spst fi 15327218Spst 15445096Simp if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then 15545096Simp echo -n ' log_in_vain=YES' 15645096Simp sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 15745096Simp sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 15845096Simp fi 15945096Simp 16039267Sjkoshy if [ X"$icmp_bmcastecho" = X"YES" ]; then 16139267Sjkoshy echo -n ' broadcast ping responses=YES' 16239267Sjkoshy sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 16339267Sjkoshy fi 16439267Sjkoshy 16525184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 16625365Sjkh echo -n ' IP gateway=YES' 16725184Sjkh sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 16825184Sjkh fi 16925184Sjkh 17033439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 17133439Sguido echo -n ' do source routing=YES' 17233439Sguido sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 17333439Sguido fi 17433439Sguido 17533439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 17633439Sguido echo -n ' accept source routing=YES' 17733439Sguido sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 17833439Sguido fi 17933439Sguido 18025184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 18125365Sjkh echo -n ' IPX gateway=YES' 18225184Sjkh sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 18325184Sjkh fi 18425184Sjkh 18536174Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 18636174Sjkh echo -n ' enabling ARP_PROXY_ALL: ' 18736174Sjkh sysctl -w net.link.ether.inet.proxyall=1 2>&1 18836174Sjkh fi 18936174Sjkh echo '.' 19036174Sjkh 19136174Sjkh echo -n 'routing daemons:' 19236174Sjkh if [ "X$router_enable" = X"YES" ]; then 19336174Sjkh echo -n " ${router}"; ${router} ${router_flags} 19436174Sjkh fi 19536174Sjkh 19625184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 19736174Sjkh echo -n ' IPXrouted' 19825184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 19925184Sjkh fi 20025765Sjkh 20136174Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 20236174Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 20325765Sjkh fi 20436174Sjkh 20534395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 20634395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 20734395Sjkh fi 20825184Sjkh echo '.' 20925184Sjkh network_pass1_done=YES # Let future generations know we made it. 21025184Sjkh} 21125184Sjkh 21225184Sjkhnetwork_pass2() { 21325184Sjkh echo -n 'Doing additional network setup:' 21425184Sjkh if [ "X${named_enable}" = X"YES" ]; then 21532949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 21625184Sjkh fi 21725184Sjkh 21831472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 21935787Sandreas echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 22031472Sobrien fi 22125184Sjkh 22231472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 22335787Sandreas echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 22425184Sjkh fi 22525184Sjkh 22625184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 22725184Sjkh echo -n ' timed'; timed ${timed_flags} 22825184Sjkh fi 22925184Sjkh 23025184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 23144668Sjfitz echo -n ' portmap'; ${portmap_program} ${portmap_flags} 23225184Sjkh fi 23325184Sjkh 23425184Sjkh # Start ypserv if we're an NIS server. 23525184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 23625184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 23725184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 23825184Sjkh 23925184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 24025184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 24125184Sjkh fi 24225184Sjkh 24325184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 24425184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 24525184Sjkh fi 24625184Sjkh fi 24725184Sjkh 24825184Sjkh # Start ypbind if we're an NIS client 24925184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 25025184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 25125184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 25225184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 25325184Sjkh fi 25425184Sjkh fi 25525184Sjkh 25635149Smarkm # Start keyserv if we are running Secure RPC 25735149Smarkm if [ "X${keyserv_enable}" = X"YES" ]; then 25835149Smarkm echo -n ' keyserv'; keyserv ${keyserv_flags} 25935149Smarkm fi 26035149Smarkm # Start ypupdated if we are running Secure RPC and we are NIS master 26135149Smarkm if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 26235149Smarkm echo -n ' rpc.ypupdated'; rpc.ypupdated 26335149Smarkm fi 26435149Smarkm 26540006Sphk # Start ATM daemons 26640006Sphk if [ -n "${atm_pass2_done}" ]; then 26740006Sphk atm_pass3 26840006Sphk fi 26940006Sphk 27025184Sjkh echo '.' 27125184Sjkh network_pass2_done=YES 27225184Sjkh} 27325184Sjkh 27425184Sjkhnetwork_pass3() { 27525184Sjkh echo -n 'Starting final network daemons:' 27625184Sjkh 27725184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 27825184Sjkh echo -n ' mountd' 27925184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 28025184Sjkh mountd_flags="-n" 28125184Sjkh fi 28225184Sjkh mountd ${mountd_flags} 28325184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 28425184Sjkh sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 28525184Sjkh fi 28625916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 28725184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 28825184Sjkh echo -n ' rpc.lockd'; rpc.lockd 28925184Sjkh fi 29025184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 29125184Sjkh echo -n ' rpc.statd'; rpc.statd 29225184Sjkh fi 29325184Sjkh fi 29425184Sjkh 29525184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 29625916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 29741371Sjkoshy if [ "X${nfs_access_cache}" != X ]; then 29841371Sjkoshy sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 29941371Sjkoshy >/dev/null 2>&1 30041185Smsmith fi 30125184Sjkh fi 30225184Sjkh 30325184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 30425184Sjkh echo -n ' amd' 30535459Sphk if [ "X${amd_map_program}" != X"NO" ]; then 30639380Scracauer amd_flags="${amd_flags} `eval ${amd_map_program}`" 30735459Sphk fi 30825184Sjkh amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 30925184Sjkh fi 31025184Sjkh 31125184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 31242270Sjkh echo -n ' rwhod'; rwhod ${rwhod_flags} 31325184Sjkh fi 31425184Sjkh 31525184Sjkh # Kerberos runs ONLY on the Kerberos server machine 31625184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 31731033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 31831033Ssef stash_flag=-n 31931033Ssef else 32031033Ssef stash_flag= 32131033Ssef fi 32231033Ssef echo -n ' kerberos'; \ 32338316Sphk kerberos ${stash_flag} >> /var/log/kerberos.log & 32431033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 32531033Ssef echo -n ' kadmind'; \ 32638316Sphk (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 32731033Ssef fi 32831033Ssef unset stash_flag 32925184Sjkh fi 33025184Sjkh 33125184Sjkh echo '.' 33225184Sjkh network_pass3_done=YES 33325184Sjkh} 334