network.subr revision 44992
125184Sjkh#!/bin/sh - 225184Sjkh# 344992Sbrian# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz 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 15439267Sjkoshy if [ X"$icmp_bmcastecho" = X"YES" ]; then 15539267Sjkoshy echo -n ' broadcast ping responses=YES' 15639267Sjkoshy sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 15739267Sjkoshy fi 15839267Sjkoshy 15925184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 16025365Sjkh echo -n ' IP gateway=YES' 16125184Sjkh sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 16225184Sjkh fi 16325184Sjkh 16433439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 16533439Sguido echo -n ' do source routing=YES' 16633439Sguido sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 16733439Sguido fi 16833439Sguido 16933439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 17033439Sguido echo -n ' accept source routing=YES' 17133439Sguido sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 17233439Sguido fi 17333439Sguido 17425184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 17525365Sjkh echo -n ' IPX gateway=YES' 17625184Sjkh sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 17725184Sjkh fi 17825184Sjkh 17936174Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 18036174Sjkh echo -n ' enabling ARP_PROXY_ALL: ' 18136174Sjkh sysctl -w net.link.ether.inet.proxyall=1 2>&1 18236174Sjkh fi 18336174Sjkh echo '.' 18436174Sjkh 18536174Sjkh echo -n 'routing daemons:' 18636174Sjkh if [ "X$router_enable" = X"YES" ]; then 18736174Sjkh echo -n " ${router}"; ${router} ${router_flags} 18836174Sjkh fi 18936174Sjkh 19025184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 19136174Sjkh echo -n ' IPXrouted' 19225184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 19325184Sjkh fi 19425765Sjkh 19536174Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 19636174Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 19725765Sjkh fi 19836174Sjkh 19934395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 20034395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 20134395Sjkh fi 20225184Sjkh echo '.' 20325184Sjkh network_pass1_done=YES # Let future generations know we made it. 20425184Sjkh} 20525184Sjkh 20625184Sjkhnetwork_pass2() { 20725184Sjkh echo -n 'Doing additional network setup:' 20825184Sjkh if [ "X${named_enable}" = X"YES" ]; then 20932949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 21025184Sjkh fi 21125184Sjkh 21231472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 21335787Sandreas echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 21431472Sobrien fi 21525184Sjkh 21631472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 21735787Sandreas echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 21825184Sjkh fi 21925184Sjkh 22025184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 22125184Sjkh echo -n ' timed'; timed ${timed_flags} 22225184Sjkh fi 22325184Sjkh 22425184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 22544668Sjfitz echo -n ' portmap'; ${portmap_program} ${portmap_flags} 22625184Sjkh fi 22725184Sjkh 22825184Sjkh # Start ypserv if we're an NIS server. 22925184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 23025184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 23125184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 23225184Sjkh 23325184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 23425184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 23525184Sjkh fi 23625184Sjkh 23725184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 23825184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 23925184Sjkh fi 24025184Sjkh fi 24125184Sjkh 24225184Sjkh # Start ypbind if we're an NIS client 24325184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 24425184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 24525184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 24625184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 24725184Sjkh fi 24825184Sjkh fi 24925184Sjkh 25035149Smarkm # Start keyserv if we are running Secure RPC 25135149Smarkm if [ "X${keyserv_enable}" = X"YES" ]; then 25235149Smarkm echo -n ' keyserv'; keyserv ${keyserv_flags} 25335149Smarkm fi 25435149Smarkm # Start ypupdated if we are running Secure RPC and we are NIS master 25535149Smarkm if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 25635149Smarkm echo -n ' rpc.ypupdated'; rpc.ypupdated 25735149Smarkm fi 25835149Smarkm 25940006Sphk # Start ATM daemons 26040006Sphk if [ -n "${atm_pass2_done}" ]; then 26140006Sphk atm_pass3 26240006Sphk fi 26340006Sphk 26425184Sjkh echo '.' 26525184Sjkh network_pass2_done=YES 26625184Sjkh} 26725184Sjkh 26825184Sjkhnetwork_pass3() { 26925184Sjkh echo -n 'Starting final network daemons:' 27025184Sjkh 27125184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 27225184Sjkh echo -n ' mountd' 27325184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 27425184Sjkh mountd_flags="-n" 27525184Sjkh fi 27625184Sjkh mountd ${mountd_flags} 27725184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 27825184Sjkh sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 27925184Sjkh fi 28025916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 28125184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 28225184Sjkh echo -n ' rpc.lockd'; rpc.lockd 28325184Sjkh fi 28425184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 28525184Sjkh echo -n ' rpc.statd'; rpc.statd 28625184Sjkh fi 28725184Sjkh fi 28825184Sjkh 28925184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 29025916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 29141371Sjkoshy if [ "X${nfs_access_cache}" != X ]; then 29241371Sjkoshy sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 29341371Sjkoshy >/dev/null 2>&1 29441185Smsmith fi 29525184Sjkh fi 29625184Sjkh 29725184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 29825184Sjkh echo -n ' amd' 29935459Sphk if [ "X${amd_map_program}" != X"NO" ]; then 30039380Scracauer amd_flags="${amd_flags} `eval ${amd_map_program}`" 30135459Sphk fi 30225184Sjkh amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 30325184Sjkh fi 30425184Sjkh 30525184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 30642270Sjkh echo -n ' rwhod'; rwhod ${rwhod_flags} 30725184Sjkh fi 30825184Sjkh 30925184Sjkh # Kerberos runs ONLY on the Kerberos server machine 31025184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 31131033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 31231033Ssef stash_flag=-n 31331033Ssef else 31431033Ssef stash_flag= 31531033Ssef fi 31631033Ssef echo -n ' kerberos'; \ 31738316Sphk kerberos ${stash_flag} >> /var/log/kerberos.log & 31831033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 31931033Ssef echo -n ' kadmind'; \ 32038316Sphk (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 32131033Ssef fi 32231033Ssef unset stash_flag 32325184Sjkh fi 32425184Sjkh 32525184Sjkh echo '.' 32625184Sjkh network_pass3_done=YES 32725184Sjkh} 328