defaultroute revision 39380
125184Sjkh#!/bin/sh - 225184Sjkh# 339380Scracauer# $Id: rc.network,v 1.31 1998/09/15 10:49:02 jkoshy 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 2825184Sjkh # Set up all the network interfaces, calling startup scripts if needed 2925184Sjkh for ifn in ${network_interfaces}; do 3025184Sjkh if [ -e /etc/start_if.${ifn} ]; then 3133682Sbrian . /etc/start_if.${ifn} 3225184Sjkh fi 3325184Sjkh # Do the primary ifconfig if specified 3425184Sjkh eval ifconfig_args=\$ifconfig_${ifn} 3525184Sjkh if [ -n "${ifconfig_args}" ] ; then 3625184Sjkh ifconfig ${ifn} ${ifconfig_args} 3725184Sjkh fi 3825184Sjkh # Check to see if aliases need to be added 3925184Sjkh alias=0 4025184Sjkh while : 4125184Sjkh do 4225184Sjkh eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} 4325184Sjkh if [ -n "${ifconfig_args}" ]; then 4425184Sjkh ifconfig ${ifn} ${ifconfig_args} alias 4525184Sjkh alias=`expr ${alias} + 1` 4625184Sjkh else 4725184Sjkh break; 4825184Sjkh fi 4925184Sjkh done 5025184Sjkh # Do ipx address if specified 5125184Sjkh eval ifconfig_args=\$ifconfig_${ifn}_ipx 5225184Sjkh if [ -n "${ifconfig_args}" ]; then 5325184Sjkh ifconfig ${ifn} ${ifconfig_args} 5425184Sjkh fi 5525184Sjkh ifconfig ${ifn} 5625184Sjkh done 5729300Sdanny 5829300Sdanny # Initialize IP filtering using ipfw 5929300Sdanny echo "" 6029300Sdanny /sbin/ipfw -q flush > /dev/null 2>&1 6132382Salex if [ $? = 0 ] ; then 6232382Salex firewall_in_kernel=1 6332382Salex else 6429300Sdanny firewall_in_kernel=0 6529300Sdanny fi 6629300Sdanny 6729300Sdanny if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 6836174Sjkh if modload /lkm/ipfw_mod.o; then 6929300Sdanny firewall_in_kernel=1 # module loaded successfully 7029300Sdanny echo "Kernel firewall module loaded." 7129300Sdanny else 7229300Sdanny echo "Warning: firewall kernel module failed to load." 7329300Sdanny fi 7429300Sdanny fi 7529300Sdanny 7629300Sdanny # Load the filters if required 7729300Sdanny if [ $firewall_in_kernel = 1 ]; then 7829300Sdanny if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \ 7929300Sdanny "x$firewall_enable" = "xYES" ] ; then 8025364Sjkh . /etc/rc.firewall 8129300Sdanny echo "Firewall rules loaded." 8229300Sdanny else 8333337Salex IPFW_DEFAULT=`ipfw l 65535` 8433337Salex if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 8533149Salex echo -n "Warning: kernel has firewall functionality, " 8633149Salex echo "but firewall rules are not enabled." 8733149Salex echo " All ip services are disabled." 8833149Salex fi 8929300Sdanny fi 9025184Sjkh fi 9125184Sjkh 9229300Sdanny # Configure routing 9329300Sdanny 9425184Sjkh if [ "x$defaultrouter" != "xNO" ] ; then 9525184Sjkh static_routes="default ${static_routes}" 9625184Sjkh route_default="default ${defaultrouter}" 9725184Sjkh fi 9825184Sjkh 9925184Sjkh # Set up any static routes. This should be done before router discovery. 10025184Sjkh if [ "x${static_routes}" != "x" ]; then 10125184Sjkh for i in ${static_routes}; do 10225184Sjkh eval route_args=\$route_${i} 10325184Sjkh route add ${route_args} 10425184Sjkh done 10525184Sjkh fi 10625184Sjkh 10725184Sjkh echo -n 'Additional routing options:' 10827218Spst if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 10927218Spst echo -n ' tcp extensions=NO' 11027218Spst sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 11127218Spst fi 11227218Spst 11339267Sjkoshy if [ X"$icmp_bmcastecho" = X"YES" ]; then 11439267Sjkoshy echo -n ' broadcast ping responses=YES' 11539267Sjkoshy sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 11639267Sjkoshy fi 11739267Sjkoshy 11825184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 11925365Sjkh echo -n ' IP gateway=YES' 12025184Sjkh sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 12125184Sjkh fi 12225184Sjkh 12333439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 12433439Sguido echo -n ' do source routing=YES' 12533439Sguido sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 12633439Sguido fi 12733439Sguido 12833439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 12933439Sguido echo -n ' accept source routing=YES' 13033439Sguido sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 13133439Sguido fi 13233439Sguido 13325184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 13425365Sjkh echo -n ' IPX gateway=YES' 13525184Sjkh sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 13625184Sjkh fi 13725184Sjkh 13836174Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 13936174Sjkh echo -n ' enabling ARP_PROXY_ALL: ' 14036174Sjkh sysctl -w net.link.ether.inet.proxyall=1 2>&1 14136174Sjkh fi 14236174Sjkh echo '.' 14336174Sjkh 14436174Sjkh echo -n 'routing daemons:' 14536174Sjkh if [ "X$router_enable" = X"YES" ]; then 14636174Sjkh echo -n " ${router}"; ${router} ${router_flags} 14736174Sjkh fi 14836174Sjkh 14925184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 15036174Sjkh echo -n ' IPXrouted' 15125184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 15225184Sjkh fi 15325765Sjkh 15436174Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 15536174Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 15625765Sjkh fi 15736174Sjkh 15834395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 15934395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 16034395Sjkh fi 16125184Sjkh echo '.' 16225184Sjkh network_pass1_done=YES # Let future generations know we made it. 16325184Sjkh} 16425184Sjkh 16525184Sjkhnetwork_pass2() { 16625184Sjkh echo -n 'Doing additional network setup:' 16725184Sjkh if [ "X${named_enable}" = X"YES" ]; then 16832949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 16925184Sjkh fi 17025184Sjkh 17131472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 17235787Sandreas echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 17331472Sobrien fi 17425184Sjkh 17531472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 17635787Sandreas echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 17725184Sjkh fi 17825184Sjkh 17925184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 18025184Sjkh echo -n ' timed'; timed ${timed_flags} 18125184Sjkh fi 18225184Sjkh 18325184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 18425184Sjkh echo -n ' portmap'; portmap ${portmap_flags} 18525184Sjkh fi 18625184Sjkh 18725184Sjkh # Start ypserv if we're an NIS server. 18825184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 18925184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 19025184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 19125184Sjkh 19225184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 19325184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 19425184Sjkh fi 19525184Sjkh 19625184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 19725184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 19825184Sjkh fi 19925184Sjkh fi 20025184Sjkh 20125184Sjkh # Start ypbind if we're an NIS client 20225184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 20325184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 20425184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 20525184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 20625184Sjkh fi 20725184Sjkh fi 20825184Sjkh 20935149Smarkm # Start keyserv if we are running Secure RPC 21035149Smarkm if [ "X${keyserv_enable}" = X"YES" ]; then 21135149Smarkm echo -n ' keyserv'; keyserv ${keyserv_flags} 21235149Smarkm fi 21335149Smarkm # Start ypupdated if we are running Secure RPC and we are NIS master 21435149Smarkm if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 21535149Smarkm echo -n ' rpc.ypupdated'; rpc.ypupdated 21635149Smarkm fi 21735149Smarkm 21825184Sjkh echo '.' 21925184Sjkh network_pass2_done=YES 22025184Sjkh} 22125184Sjkh 22225184Sjkhnetwork_pass3() { 22325184Sjkh echo -n 'Starting final network daemons:' 22425184Sjkh 22525184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 22625184Sjkh echo -n ' mountd' 22725184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 22825184Sjkh mountd_flags="-n" 22925184Sjkh fi 23025184Sjkh mountd ${mountd_flags} 23125184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 23225184Sjkh sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 23325184Sjkh fi 23425916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 23525184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 23625184Sjkh echo -n ' rpc.lockd'; rpc.lockd 23725184Sjkh fi 23825184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 23925184Sjkh echo -n ' rpc.statd'; rpc.statd 24025184Sjkh fi 24125184Sjkh fi 24225184Sjkh 24325184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 24425916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 24525184Sjkh fi 24625184Sjkh 24725184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 24825184Sjkh echo -n ' amd' 24935459Sphk if [ "X${amd_map_program}" != X"NO" ]; then 25039380Scracauer amd_flags="${amd_flags} `eval ${amd_map_program}`" 25135459Sphk fi 25225184Sjkh amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 25325184Sjkh fi 25425184Sjkh 25525184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 25625184Sjkh echo -n ' rwhod'; rwhod 25725184Sjkh fi 25825184Sjkh 25925184Sjkh # Kerberos runs ONLY on the Kerberos server machine 26025184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 26131033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 26231033Ssef stash_flag=-n 26331033Ssef else 26431033Ssef stash_flag= 26531033Ssef fi 26631033Ssef echo -n ' kerberos'; \ 26738316Sphk kerberos ${stash_flag} >> /var/log/kerberos.log & 26831033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 26931033Ssef echo -n ' kadmind'; \ 27038316Sphk (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 27131033Ssef fi 27231033Ssef unset stash_flag 27325184Sjkh fi 27425184Sjkh 27535267Sbrian # Network Address Translation daemon 27637514Snectar if [ "X${natd_enable}" = X"YES" -a X"${natd_interface}" != X"" \ 27737514Snectar -a X"${firewall_enable}" = X"YES" ]; then 27837514Snectar if echo ${natd_interface} | \ 27937514Snectar grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 28037514Snectar natd_ifarg="-a ${natd_interface}" 28137514Snectar else 28237514Snectar natd_ifarg="-n ${natd_interface}" 28337514Snectar fi 28437514Snectar echo -n ' natd'; natd ${natd_flags} ${natd_ifarg} 28537514Snectar fi 28635267Sbrian 28725184Sjkh echo '.' 28825184Sjkh network_pass3_done=YES 28925184Sjkh} 290