defaultroute revision 34395
125184Sjkh#!/bin/sh - 225184Sjkh# 334395Sjkh# $Id: rc.network,v 1.19 1998/02/20 14:45:06 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 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 6829300Sdanny modload /lkm/ipfw_mod.o 6929300Sdanny if [ $? = 0 ]; then 7029300Sdanny firewall_in_kernel=1 # module loaded successfully 7129300Sdanny echo "Kernel firewall module loaded." 7229300Sdanny else 7329300Sdanny echo "Warning: firewall kernel module failed to load." 7429300Sdanny fi 7529300Sdanny fi 7629300Sdanny 7729300Sdanny # Load the filters if required 7829300Sdanny if [ $firewall_in_kernel = 1 ]; then 7929300Sdanny if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \ 8029300Sdanny "x$firewall_enable" = "xYES" ] ; then 8125364Sjkh . /etc/rc.firewall 8229300Sdanny echo "Firewall rules loaded." 8329300Sdanny else 8433337Salex IPFW_DEFAULT=`ipfw l 65535` 8533337Salex if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 8633149Salex echo -n "Warning: kernel has firewall functionality, " 8733149Salex echo "but firewall rules are not enabled." 8833149Salex echo " All ip services are disabled." 8933149Salex fi 9029300Sdanny fi 9125184Sjkh fi 9225184Sjkh 9329300Sdanny # Configure routing 9429300Sdanny 9525184Sjkh if [ "x$defaultrouter" != "xNO" ] ; then 9625184Sjkh static_routes="default ${static_routes}" 9725184Sjkh route_default="default ${defaultrouter}" 9825184Sjkh fi 9925184Sjkh 10025184Sjkh # Set up any static routes. This should be done before router discovery. 10125184Sjkh if [ "x${static_routes}" != "x" ]; then 10225184Sjkh for i in ${static_routes}; do 10325184Sjkh eval route_args=\$route_${i} 10425184Sjkh route add ${route_args} 10525184Sjkh done 10625184Sjkh fi 10725184Sjkh 10825184Sjkh echo -n 'Additional routing options:' 10927218Spst if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 11027218Spst echo -n ' tcp extensions=NO' 11127218Spst sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 11227218Spst sysctl -w net.inet.tcp.rfc1644=0 >/dev/null 2>&1 11327218Spst fi 11427218Spst 11525184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 11625365Sjkh echo -n ' IP gateway=YES' 11725184Sjkh sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 11825184Sjkh fi 11925184Sjkh 12033439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 12133439Sguido echo -n ' do source routing=YES' 12233439Sguido sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 12333439Sguido fi 12433439Sguido 12533439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 12633439Sguido echo -n ' accept source routing=YES' 12733439Sguido sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 12833439Sguido fi 12933439Sguido 13025184Sjkh if [ "X$router_enable" = X"YES" ]; then 13125184Sjkh echo -n " ${router}"; ${router} ${router_flags} 13225184Sjkh fi 13325184Sjkh 13425184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 13525365Sjkh echo -n ' IPX gateway=YES' 13625184Sjkh sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 13725184Sjkh fi 13825184Sjkh 13925184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 14025184Sjkh echo -n ' IPXrouted: ' 14125184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 14225184Sjkh fi 14325765Sjkh 14425765Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 14525765Sjkh echo -n ' enabling ARP_PROXY_ALL: ' 14625765Sjkh sysctl -w net.link.ether.inet.proxyall=1 2>&1 14725765Sjkh fi 14834395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 14934395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 15034395Sjkh fi 15134395Sjkh 15225184Sjkh echo '.' 15325184Sjkh network_pass1_done=YES # Let future generations know we made it. 15425184Sjkh} 15525184Sjkh 15625184Sjkhnetwork_pass2() { 15725184Sjkh echo -n 'Doing additional network setup:' 15825184Sjkh if [ "X${named_enable}" = X"YES" ]; then 15932949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 16025184Sjkh fi 16125184Sjkh 16231472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 16331472Sobrien echo -n ' ntpdate'; ntpdate ${ntpdate_flags} >/dev/null 2>&1 16431472Sobrien fi 16525184Sjkh 16631472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 16731472Sobrien echo -n ' xntpd'; xntpd ${xntpd_flags} 16825184Sjkh fi 16925184Sjkh 17025184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 17125184Sjkh echo -n ' timed'; timed ${timed_flags} 17225184Sjkh fi 17325184Sjkh 17425184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 17525184Sjkh echo -n ' portmap'; portmap ${portmap_flags} 17625184Sjkh fi 17725184Sjkh 17825184Sjkh # Start ypserv if we're an NIS server. 17925184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 18025184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 18125184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 18225184Sjkh 18325184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 18425184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 18525184Sjkh fi 18625184Sjkh 18725184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 18825184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 18925184Sjkh fi 19025184Sjkh fi 19125184Sjkh 19225184Sjkh # Start ypbind if we're an NIS client 19325184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 19425184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 19525184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 19625184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 19725184Sjkh fi 19825184Sjkh fi 19925184Sjkh 20025184Sjkh echo '.' 20125184Sjkh network_pass2_done=YES 20225184Sjkh} 20325184Sjkh 20425184Sjkhnetwork_pass3() { 20525184Sjkh echo -n 'Starting final network daemons:' 20625184Sjkh 20725184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 20825184Sjkh echo -n ' mountd' 20925184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 21025184Sjkh mountd_flags="-n" 21125184Sjkh fi 21225184Sjkh mountd ${mountd_flags} 21325184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 21425365Sjkh echo -n ' nfsprivport=YES' 21525184Sjkh sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 21625184Sjkh fi 21725916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 21825184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 21925184Sjkh echo -n ' rpc.lockd'; rpc.lockd 22025184Sjkh fi 22125184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 22225184Sjkh echo -n ' rpc.statd'; rpc.statd 22325184Sjkh fi 22425184Sjkh fi 22525184Sjkh 22625184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 22725916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 22825184Sjkh fi 22925184Sjkh 23025184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 23125184Sjkh echo -n ' amd' 23225184Sjkh amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 23325184Sjkh fi 23425184Sjkh 23525184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 23625184Sjkh echo -n ' rwhod'; rwhod 23725184Sjkh fi 23825184Sjkh 23925184Sjkh # Kerberos runs ONLY on the Kerberos server machine 24025184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 24131033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 24231033Ssef stash_flag=-n 24331033Ssef else 24431033Ssef stash_flag= 24531033Ssef fi 24631033Ssef echo -n ' kerberos'; \ 24731033Ssef kerberos ${stash_flags} >> /var/log/kerberos.log & 24831033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 24931033Ssef echo -n ' kadmind'; \ 25031033Ssef (sleep 20; kadmind ${stash_flags} >/dev/null 2>&1 &) & 25131033Ssef fi 25231033Ssef unset stash_flag 25325184Sjkh fi 25425184Sjkh 25525184Sjkh # IP multicast routing daemon 25625184Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 25725184Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 25825184Sjkh fi 25925184Sjkh echo '.' 26025184Sjkh network_pass3_done=YES 26125184Sjkh} 262