defaultroute revision 48842
125184Sjkh#!/bin/sh - 225184Sjkh# 348842Sjkh# $Id: rc.network,v 1.49 1999/07/08 18:56:02 peter 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 5448687Speter if [ "x${network_interfaces}" = "xauto" ]; then 5548687Speter network_interfaces="`ifconfig -l`" 5648687Speter fi 5748687Speter for ifn in ${network_interfaces}; do 5848662Speter showstat=false 5925184Sjkh if [ -e /etc/start_if.${ifn} ]; then 6033682Sbrian . /etc/start_if.${ifn} 6148662Speter showstat=true 6225184Sjkh fi 6325184Sjkh # Do the primary ifconfig if specified 6425184Sjkh eval ifconfig_args=\$ifconfig_${ifn} 6525184Sjkh if [ -n "${ifconfig_args}" ] ; then 6648842Sjkh # See if we are using DHCP 6748842Sjkh if [ X"${ifconfig_args}" = X"DHCP" ]; then 6848842Sjkh ${dhcp_program} ${dhcp_flags} ${ifn} 6948842Sjkh else 7048842Sjkh ifconfig ${ifn} ${ifconfig_args} 7148842Sjkh fi 7248662Speter showstat=true 7325184Sjkh fi 7425184Sjkh # Check to see if aliases need to be added 7525184Sjkh alias=0 7625184Sjkh while : 7725184Sjkh do 7825184Sjkh eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} 7925184Sjkh if [ -n "${ifconfig_args}" ]; then 8025184Sjkh ifconfig ${ifn} ${ifconfig_args} alias 8148662Speter showstat=true 8225184Sjkh alias=`expr ${alias} + 1` 8325184Sjkh else 8425184Sjkh break; 8525184Sjkh fi 8625184Sjkh done 8725184Sjkh # Do ipx address if specified 8825184Sjkh eval ifconfig_args=\$ifconfig_${ifn}_ipx 8925184Sjkh if [ -n "${ifconfig_args}" ]; then 9025184Sjkh ifconfig ${ifn} ${ifconfig_args} 9148662Speter showstat=true 9225184Sjkh fi 9348662Speter if [ "${showstat}" = "true" ] 9448662Speter then 9548662Speter ifconfig ${ifn} 9648662Speter fi 9725184Sjkh done 9829300Sdanny 9929300Sdanny # Initialize IP filtering using ipfw 10029300Sdanny echo "" 10129300Sdanny /sbin/ipfw -q flush > /dev/null 2>&1 10232382Salex if [ $? = 0 ] ; then 10332382Salex firewall_in_kernel=1 10432382Salex else 10529300Sdanny firewall_in_kernel=0 10629300Sdanny fi 10729300Sdanny 10829300Sdanny if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 10941077Speter if kldload ipfw; then 11029300Sdanny firewall_in_kernel=1 # module loaded successfully 11129300Sdanny echo "Kernel firewall module loaded." 11229300Sdanny else 11329300Sdanny echo "Warning: firewall kernel module failed to load." 11429300Sdanny fi 11529300Sdanny fi 11629300Sdanny 11729300Sdanny # Load the filters if required 11829300Sdanny if [ $firewall_in_kernel = 1 ]; then 11945542Sdes if [ -z "${firewall_script}" ] ; then 12045542Sdes firewall_script="/etc/rc.firewall" 12145542Sdes fi 12245542Sdes if [ -f ${firewall_script} -a X"$firewall_enable" = X"YES" ]; then 12345542Sdes . ${firewall_script} 12445622Sbrian echo -n 'Firewall rules loaded, starting divert daemons:' 12544992Sbrian 12644992Sbrian # Network Address Translation daemon 12744992Sbrian if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then 12844992Sbrian if echo ${natd_interface} | \ 12944992Sbrian grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 13044992Sbrian natd_ifarg="-a ${natd_interface}" 13144992Sbrian else 13244992Sbrian natd_ifarg="-n ${natd_interface}" 13344992Sbrian fi 13444992Sbrian echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 13544992Sbrian fi 13644992Sbrian echo '.' 13729300Sdanny else 13833337Salex IPFW_DEFAULT=`ipfw l 65535` 13933337Salex if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 14033149Salex echo -n "Warning: kernel has firewall functionality, " 14133149Salex echo "but firewall rules are not enabled." 14233149Salex echo " All ip services are disabled." 14333149Salex fi 14429300Sdanny fi 14525184Sjkh fi 14625184Sjkh 14740006Sphk # Additional ATM interface configuration 14840006Sphk if [ -n "${atm_pass1_done}" ]; then 14940006Sphk atm_pass2 15040006Sphk fi 15140006Sphk 15229300Sdanny # Configure routing 15329300Sdanny 15425184Sjkh if [ "x$defaultrouter" != "xNO" ] ; then 15525184Sjkh static_routes="default ${static_routes}" 15625184Sjkh route_default="default ${defaultrouter}" 15725184Sjkh fi 15825184Sjkh 15925184Sjkh # Set up any static routes. This should be done before router discovery. 16025184Sjkh if [ "x${static_routes}" != "x" ]; then 16125184Sjkh for i in ${static_routes}; do 16225184Sjkh eval route_args=\$route_${i} 16325184Sjkh route add ${route_args} 16425184Sjkh done 16525184Sjkh fi 16625184Sjkh 16725184Sjkh echo -n 'Additional routing options:' 16827218Spst if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 16927218Spst echo -n ' tcp extensions=NO' 17047755Sbde sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 17127218Spst fi 17227218Spst 17345096Simp if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then 17445096Simp echo -n ' log_in_vain=YES' 17547755Sbde sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 17647755Sbde sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 17745096Simp fi 17845096Simp 17939267Sjkoshy if [ X"$icmp_bmcastecho" = X"YES" ]; then 18039267Sjkoshy echo -n ' broadcast ping responses=YES' 18147755Sbde sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 18239267Sjkoshy fi 18339267Sjkoshy 18425184Sjkh if [ "X$gateway_enable" = X"YES" ]; then 18525365Sjkh echo -n ' IP gateway=YES' 18647755Sbde sysctl -w net.inet.ip.forwarding=1 >/dev/null 18725184Sjkh fi 18825184Sjkh 18933439Sguido if [ "X$forward_sourceroute" = X"YES" ]; then 19033439Sguido echo -n ' do source routing=YES' 19147755Sbde sysctl -w net.inet.ip.sourceroute=1 >/dev/null 19233439Sguido fi 19333439Sguido 19433439Sguido if [ "X$accept_sourceroute" = X"YES" ]; then 19533439Sguido echo -n ' accept source routing=YES' 19647755Sbde sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 19733439Sguido fi 19833439Sguido 19947752Sphk if [ "X$tcp_keepalive" = X"YES" ]; then 20047752Sphk echo -n ' TCP keepalive=YES' 20147755Sbde sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null 20247752Sphk fi 20347752Sphk 20425184Sjkh if [ "X$ipxgateway_enable" = X"YES" ]; then 20525365Sjkh echo -n ' IPX gateway=YES' 20647755Sbde sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 20725184Sjkh fi 20825184Sjkh 20936174Sjkh if [ "X$arpproxy_all" = X"YES" ]; then 21047755Sbde echo -n ' ARP proxyall=YES' 21147755Sbde sysctl -w net.link.ether.inet.proxyall=1 >/dev/null 21236174Sjkh fi 21336174Sjkh echo '.' 21436174Sjkh 21536174Sjkh echo -n 'routing daemons:' 21636174Sjkh if [ "X$router_enable" = X"YES" ]; then 21736174Sjkh echo -n " ${router}"; ${router} ${router_flags} 21836174Sjkh fi 21936174Sjkh 22025184Sjkh if [ "X$ipxrouted_enable" = X"YES" ]; then 22136174Sjkh echo -n ' IPXrouted' 22225184Sjkh IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 22325184Sjkh fi 22425765Sjkh 22536174Sjkh if [ "X${mrouted_enable}" = X"YES" ]; then 22636174Sjkh echo -n ' mrouted'; mrouted ${mrouted_flags} 22725765Sjkh fi 22836174Sjkh 22934395Sjkh if [ "X$rarpd_enable" = X"YES" ]; then 23034395Sjkh echo -n ' rarpd'; rarpd ${rarpd_flags} 23134395Sjkh fi 23225184Sjkh echo '.' 23325184Sjkh network_pass1_done=YES # Let future generations know we made it. 23425184Sjkh} 23525184Sjkh 23625184Sjkhnetwork_pass2() { 23725184Sjkh echo -n 'Doing additional network setup:' 23825184Sjkh if [ "X${named_enable}" = X"YES" ]; then 23932949Swollman echo -n ' named'; ${named_program-"named"} ${named_flags} 24025184Sjkh fi 24125184Sjkh 24231472Sobrien if [ "X${ntpdate_enable}" = X"YES" ]; then 24335787Sandreas echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 24431472Sobrien fi 24525184Sjkh 24631472Sobrien if [ "X${xntpd_enable}" = X"YES" ]; then 24735787Sandreas echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 24825184Sjkh fi 24925184Sjkh 25025184Sjkh if [ "X${timed_enable}" = X"YES" ]; then 25125184Sjkh echo -n ' timed'; timed ${timed_flags} 25225184Sjkh fi 25325184Sjkh 25425184Sjkh if [ "X${portmap_enable}" = X"YES" ]; then 25544668Sjfitz echo -n ' portmap'; ${portmap_program} ${portmap_flags} 25625184Sjkh fi 25725184Sjkh 25825184Sjkh # Start ypserv if we're an NIS server. 25925184Sjkh # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 26025184Sjkh if [ "X${nis_server_enable}" = X"YES" ]; then 26125184Sjkh echo -n ' ypserv'; ypserv ${nis_server_flags} 26225184Sjkh 26325184Sjkh if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 26425184Sjkh echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 26525184Sjkh fi 26625184Sjkh 26725184Sjkh if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 26825184Sjkh echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 26925184Sjkh fi 27025184Sjkh fi 27125184Sjkh 27225184Sjkh # Start ypbind if we're an NIS client 27325184Sjkh if [ "X${nis_client_enable}" = X"YES" ]; then 27425184Sjkh echo -n ' ypbind'; ypbind ${nis_client_flags} 27525184Sjkh if [ "X${nis_ypset_enable}" = X"YES" ]; then 27625184Sjkh echo -n ' ypset'; ypset ${nis_ypset_flags} 27725184Sjkh fi 27825184Sjkh fi 27925184Sjkh 28035149Smarkm # Start keyserv if we are running Secure RPC 28135149Smarkm if [ "X${keyserv_enable}" = X"YES" ]; then 28235149Smarkm echo -n ' keyserv'; keyserv ${keyserv_flags} 28335149Smarkm fi 28435149Smarkm # Start ypupdated if we are running Secure RPC and we are NIS master 28535149Smarkm if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 28635149Smarkm echo -n ' rpc.ypupdated'; rpc.ypupdated 28735149Smarkm fi 28835149Smarkm 28940006Sphk # Start ATM daemons 29040006Sphk if [ -n "${atm_pass2_done}" ]; then 29140006Sphk atm_pass3 29240006Sphk fi 29340006Sphk 29425184Sjkh echo '.' 29525184Sjkh network_pass2_done=YES 29625184Sjkh} 29725184Sjkh 29825184Sjkhnetwork_pass3() { 29925184Sjkh echo -n 'Starting final network daemons:' 30025184Sjkh 30125184Sjkh if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 30225184Sjkh echo -n ' mountd' 30325184Sjkh if [ "X${weak_mountd_authentication}" = X"YES" ]; then 30425184Sjkh mountd_flags="-n" 30525184Sjkh fi 30625184Sjkh mountd ${mountd_flags} 30725184Sjkh if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 30847755Sbde echo -n ' NFS on reserved port only=YES' 30947755Sbde sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 31025184Sjkh fi 31125916Sjkh echo -n ' nfsd'; nfsd ${nfs_server_flags} 31225184Sjkh if [ "X$rpc_lockd_enable" = X"YES" ]; then 31325184Sjkh echo -n ' rpc.lockd'; rpc.lockd 31425184Sjkh fi 31525184Sjkh if [ "X$rpc_statd_enable" = X"YES" ]; then 31625184Sjkh echo -n ' rpc.statd'; rpc.statd 31725184Sjkh fi 31825184Sjkh fi 31925184Sjkh 32025184Sjkh if [ "X${nfs_client_enable}" = X"YES" ]; then 32125916Sjkh echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 32241371Sjkoshy if [ "X${nfs_access_cache}" != X ]; then 32347755Sbde echo -n " NFS access cache time=${nfs_access_cache}" 32441371Sjkoshy sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 32547755Sbde >/dev/null 32641185Smsmith fi 32725184Sjkh fi 32825184Sjkh 32925184Sjkh if [ "X${amd_enable}" = X"YES" ]; then 33025184Sjkh echo -n ' amd' 33135459Sphk if [ "X${amd_map_program}" != X"NO" ]; then 33239380Scracauer amd_flags="${amd_flags} `eval ${amd_map_program}`" 33335459Sphk fi 33447838Sbrian if [ -n "$amd_flags" ] 33547838Sbrian then 33647838Sbrian amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 33747838Sbrian else 33847838Sbrian amd 2> /dev/null 33947838Sbrian fi 34025184Sjkh fi 34125184Sjkh 34225184Sjkh if [ "X${rwhod_enable}" = X"YES" ]; then 34342270Sjkh echo -n ' rwhod'; rwhod ${rwhod_flags} 34425184Sjkh fi 34525184Sjkh 34625184Sjkh # Kerberos runs ONLY on the Kerberos server machine 34725184Sjkh if [ "X${kerberos_server_enable}" = X"YES" ]; then 34831033Ssef if [ "X${kerberos_stash}" = "XYES" ]; then 34931033Ssef stash_flag=-n 35031033Ssef else 35131033Ssef stash_flag= 35231033Ssef fi 35331033Ssef echo -n ' kerberos'; \ 35438316Sphk kerberos ${stash_flag} >> /var/log/kerberos.log & 35531033Ssef if [ "X${kadmind_server_enable}" = "XYES" ]; then 35631033Ssef echo -n ' kadmind'; \ 35738316Sphk (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 35831033Ssef fi 35931033Ssef unset stash_flag 36025184Sjkh fi 36125184Sjkh 36225184Sjkh echo '.' 36325184Sjkh network_pass3_done=YES 36425184Sjkh} 365