defaultroute revision 44668
125184Sjkh#!/bin/sh - 225184Sjkh# 344668Sjfitz# $Id: rc.network,v 1.39 1999/01/13 17:32:37 joerg 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 10329300Sdanny if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \ 10429300Sdanny "x$firewall_enable" = "xYES" ] ; then 10525364Sjkh . /etc/rc.firewall 10629300Sdanny echo "Firewall rules loaded." 10729300Sdanny else 10833337Salex IPFW_DEFAULT=`ipfw l 65535` 10933337Salex if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 11033149Salex echo -n "Warning: kernel has firewall functionality, " 11133149Salex echo "but firewall rules are not enabled." 11233149Salex echo " All ip services are disabled." 11333149Salex fi 11429300Sdanny fi 11525184Sjkh fi 11625184Sjkh 11740006Sphk # Additional ATM interface configuration 11840006Sphk if [ -n "${atm_pass1_done}" ]; then 11940006Sphk atm_pass2 12040006Sphk fi 12140006Sphk 12229300Sdanny # Configure routing 12329300Sdanny 12425184Sjkh if [ "x$defaultrouter" != "xNO" ] ; then 12525184Sjkh static_routes="default ${static_routes}" 12625184Sjkh route_default="default ${defaultrouter}" 12725184Sjkh fi 12825184Sjkh 12925184Sjkh # Set up any static routes. This should be done before router discovery. 13025184Sjkh if [ "x${static_routes}" != "x" ]; then 13125184Sjkh for i in ${static_routes}; do 13225184Sjkh eval route_args=\$route_${i} 13325184Sjkh route add ${route_args} 13425184Sjkh done 13525184Sjkh fi 13625184Sjkh 13725184Sjkh echo -n 'Additional routing options:' 13827218Spst if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 13927218Spst echo -n ' tcp extensions=NO' 14027218Spst sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 14127218Spst fi 14227218Spst 14339267Sjkoshy if [ X"$icmp_bmcastecho" = X"YES" ]; then 14439267Sjkoshy echo -n ' broadcast ping responses=YES' 14539267Sjkoshy sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 14639267Sjkoshy fi 14739267Sjkoshy 14825184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 14925365Sjkh echo -n ' IP gateway=YES' 15025184Sjkh sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 15125184Sjkh fi 15225184Sjkh 15333439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 15433439Sguido echo -n ' do source routing=YES' 15533439Sguido sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 15633439Sguido fi 15733439Sguido 15833439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 15933439Sguido echo -n ' accept source routing=YES' 16033439Sguido sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 16133439Sguido fi 16233439Sguido 16325184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 16425365Sjkh echo -n ' IPX gateway=YES' 16525184Sjkh sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 16625184Sjkh fi 16725184Sjkh 16836174Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 16936174Sjkh echo -n ' enabling ARP_PROXY_ALL: ' 17036174Sjkh sysctl -w net.link.ether.inet.proxyall=1 2>&1 17136174Sjkh fi 17236174Sjkh echo '.' 17336174Sjkh 17436174Sjkh echo -n 'routing daemons:' 17536174Sjkh if [ "X$router_enable" = X"YES" ]; then 17636174Sjkh echo -n " ${router}"; ${router} ${router_flags} 17736174Sjkh fi 17836174Sjkh 17925184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 18036174Sjkh echo -n ' IPXrouted' 18125184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 18225184Sjkh fi 18325765Sjkh 18436174Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 18536174Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 18625765Sjkh fi 18736174Sjkh 18834395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 18934395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 19034395Sjkh fi 19125184Sjkh echo '.' 19225184Sjkh network_pass1_done=YES # Let future generations know we made it. 19325184Sjkh} 19425184Sjkh 19525184Sjkhnetwork_pass2() { 19625184Sjkh echo -n 'Doing additional network setup:' 19725184Sjkh if [ "X${named_enable}" = X"YES" ]; then 19832949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 19925184Sjkh fi 20025184Sjkh 20131472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 20235787Sandreas echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 20331472Sobrien fi 20425184Sjkh 20531472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 20635787Sandreas echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 20725184Sjkh fi 20825184Sjkh 20925184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 21025184Sjkh echo -n ' timed'; timed ${timed_flags} 21125184Sjkh fi 21225184Sjkh 21325184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 21444668Sjfitz echo -n ' portmap'; ${portmap_program} ${portmap_flags} 21525184Sjkh fi 21625184Sjkh 21725184Sjkh # Start ypserv if we're an NIS server. 21825184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 21925184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 22025184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 22125184Sjkh 22225184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 22325184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 22425184Sjkh fi 22525184Sjkh 22625184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 22725184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 22825184Sjkh fi 22925184Sjkh fi 23025184Sjkh 23125184Sjkh # Start ypbind if we're an NIS client 23225184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 23325184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 23425184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 23525184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 23625184Sjkh fi 23725184Sjkh fi 23825184Sjkh 23935149Smarkm # Start keyserv if we are running Secure RPC 24035149Smarkm if [ "X${keyserv_enable}" = X"YES" ]; then 24135149Smarkm echo -n ' keyserv'; keyserv ${keyserv_flags} 24235149Smarkm fi 24335149Smarkm # Start ypupdated if we are running Secure RPC and we are NIS master 24435149Smarkm if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 24535149Smarkm echo -n ' rpc.ypupdated'; rpc.ypupdated 24635149Smarkm fi 24735149Smarkm 24840006Sphk # Start ATM daemons 24940006Sphk if [ -n "${atm_pass2_done}" ]; then 25040006Sphk atm_pass3 25140006Sphk fi 25240006Sphk 25325184Sjkh echo '.' 25425184Sjkh network_pass2_done=YES 25525184Sjkh} 25625184Sjkh 25725184Sjkhnetwork_pass3() { 25825184Sjkh echo -n 'Starting final network daemons:' 25925184Sjkh 26025184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 26125184Sjkh echo -n ' mountd' 26225184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 26325184Sjkh mountd_flags="-n" 26425184Sjkh fi 26525184Sjkh mountd ${mountd_flags} 26625184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 26725184Sjkh sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 26825184Sjkh fi 26925916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 27025184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 27125184Sjkh echo -n ' rpc.lockd'; rpc.lockd 27225184Sjkh fi 27325184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 27425184Sjkh echo -n ' rpc.statd'; rpc.statd 27525184Sjkh fi 27625184Sjkh fi 27725184Sjkh 27825184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 27925916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 28041371Sjkoshy if [ "X${nfs_access_cache}" != X ]; then 28141371Sjkoshy sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 28241371Sjkoshy >/dev/null 2>&1 28341185Smsmith fi 28425184Sjkh fi 28525184Sjkh 28625184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 28725184Sjkh echo -n ' amd' 28835459Sphk if [ "X${amd_map_program}" != X"NO" ]; then 28939380Scracauer amd_flags="${amd_flags} `eval ${amd_map_program}`" 29035459Sphk fi 29125184Sjkh amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 29225184Sjkh fi 29325184Sjkh 29425184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 29542270Sjkh echo -n ' rwhod'; rwhod ${rwhod_flags} 29625184Sjkh fi 29725184Sjkh 29825184Sjkh # Kerberos runs ONLY on the Kerberos server machine 29925184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 30031033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 30131033Ssef stash_flag=-n 30231033Ssef else 30331033Ssef stash_flag= 30431033Ssef fi 30531033Ssef echo -n ' kerberos'; \ 30638316Sphk kerberos ${stash_flag} >> /var/log/kerberos.log & 30731033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 30831033Ssef echo -n ' kadmind'; \ 30938316Sphk (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 31031033Ssef fi 31131033Ssef unset stash_flag 31225184Sjkh fi 31325184Sjkh 31435267Sbrian # Network Address Translation daemon 31537514Snectar if [ "X${natd_enable}" = X"YES" -a X"${natd_interface}" != X"" \ 31637514Snectar -a X"${firewall_enable}" = X"YES" ]; then 31737514Snectar if echo ${natd_interface} | \ 31837514Snectar grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 31937514Snectar natd_ifarg="-a ${natd_interface}" 32037514Snectar else 32137514Snectar natd_ifarg="-n ${natd_interface}" 32237514Snectar fi 32337514Snectar echo -n ' natd'; natd ${natd_flags} ${natd_ifarg} 32437514Snectar fi 32535267Sbrian 32625184Sjkh echo '.' 32725184Sjkh network_pass3_done=YES 32825184Sjkh} 329