defaultroute revision 35149
155992Swpaul#!/bin/sh - 255992Swpaul# 355992Swpaul# $Id$ 455992Swpaul# From: @(#)netstart 5.9 (Berkeley) 3/30/91 555992Swpaul 655992Swpaul# Note that almost all the user-configurable behavior is no longer in 755992Swpaul# this file, but rather in /etc/rc.conf. Please check that file 855992Swpaul# first before contemplating any changes here. If you do need to change 955992Swpaul# this file for some reason, we would like to know about it. 1055992Swpaul 1155992Swpaul# First pass startup stuff. 1255992Swpaul 1355992Swpaulnetwork_pass1() { 1455992Swpaul echo -n 'Doing initial network setup:' 1555992Swpaul # Set the host name if it is not already set 1655992Swpaul if [ -z "`hostname -s`" ] ; then 1755992Swpaul hostname $hostname 1855992Swpaul echo -n ' hostname' 1955992Swpaul fi 2055992Swpaul 2155992Swpaul # Set the domainname if we're using NIS 2255992Swpaul if [ -n "$nisdomainname" -a "x$nisdomainname" != "xNO" ] ; then 2355992Swpaul domainname $nisdomainname 2455992Swpaul echo -n ' domain' 2555992Swpaul fi 2655992Swpaul echo '.' 2755992Swpaul 2855992Swpaul # Set up all the network interfaces, calling startup scripts if needed 2955992Swpaul for ifn in ${network_interfaces}; do 3055992Swpaul if [ -e /etc/start_if.${ifn} ]; then 3155992Swpaul . /etc/start_if.${ifn} 3255992Swpaul fi 33148145Strhodes # Do the primary ifconfig if specified 3472768Sru eval ifconfig_args=\$ifconfig_${ifn} 3579538Sru if [ -n "${ifconfig_args}" ] ; then 3655992Swpaul ifconfig ${ifn} ${ifconfig_args} 3755992Swpaul fi 3875670Sru # Check to see if aliases need to be added 3955992Swpaul alias=0 40151046Strhodes while : 41151046Strhodes do 42148220Strhodes eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} 43148145Strhodes if [ -n "${ifconfig_args}" ]; then 4456460Sasmodai ifconfig ${ifn} ${ifconfig_args} alias 45111395Strhodes alias=`expr ${alias} + 1` 46148145Strhodes else 47148145Strhodes break; 48151046Strhodes fi 49151046Strhodes done 50148145Strhodes # Do ipx address if specified 51148145Strhodes eval ifconfig_args=\$ifconfig_${ifn}_ipx 52148145Strhodes if [ -n "${ifconfig_args}" ]; then 53148145Strhodes ifconfig ${ifn} ${ifconfig_args} 5455992Swpaul fi 5555992Swpaul ifconfig ${ifn} 5655992Swpaul done 5755992Swpaul 58122321Sbmah # Initialize IP filtering using ipfw 59122321Sbmah echo "" 60122321Sbmah /sbin/ipfw -q flush > /dev/null 2>&1 61122321Sbmah if [ $? = 0 ] ; then 62122321Sbmah firewall_in_kernel=1 63122321Sbmah else 64122321Sbmah firewall_in_kernel=0 65122321Sbmah fi 66122321Sbmah 67122321Sbmah if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 68122321Sbmah modload /lkm/ipfw_mod.o 69122321Sbmah if [ $? = 0 ]; then 7057676Ssheldonh firewall_in_kernel=1 # module loaded successfully 71122321Sbmah echo "Kernel firewall module loaded." 72122321Sbmah else 7357676Ssheldonh echo "Warning: firewall kernel module failed to load." 7455992Swpaul fi 7555992Swpaul fi 7655992Swpaul 7775282Sbillf # Load the filters if required 7855992Swpaul if [ $firewall_in_kernel = 1 ]; then 7955992Swpaul if [ -n "$firewall_enable" -a -f /etc/rc.firewall -a \ 80119169Simp "x$firewall_enable" = "xYES" ] ; then 81118871Sbrueffer . /etc/rc.firewall 82118871Sbrueffer echo "Firewall rules loaded." 83118871Sbrueffer else 8457676Ssheldonh IPFW_DEFAULT=`ipfw l 65535` 8555992Swpaul if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 8657695Ssheldonh echo -n "Warning: kernel has firewall functionality, " 8757695Ssheldonh echo "but firewall rules are not enabled." 88118871Sbrueffer echo " All ip services are disabled." 8957695Ssheldonh fi 9055992Swpaul fi 9155992Swpaul fi 9255992Swpaul 9357676Ssheldonh # Configure routing 9457676Ssheldonh 9555992Swpaul if [ "x$defaultrouter" != "xNO" ] ; then 9655992Swpaul static_routes="default ${static_routes}" 9755992Swpaul route_default="default ${defaultrouter}" 9855992Swpaul fi 9955992Swpaul 10057676Ssheldonh # Set up any static routes. This should be done before router discovery. 10157676Ssheldonh if [ "x${static_routes}" != "x" ]; then 10255992Swpaul for i in ${static_routes}; do 10355992Swpaul eval route_args=\$route_${i} 10457676Ssheldonh route add ${route_args} 10557676Ssheldonh done 10655992Swpaul fi 10755992Swpaul 10855992Swpaul echo -n 'Additional routing options:' 10955992Swpaul if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 11055992Swpaul echo -n ' tcp extensions=NO' 11174144Sassar sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 11255992Swpaul sysctl -w net.inet.tcp.rfc1644=0 >/dev/null 2>&1 11355992Swpaul fi 114118871Sbrueffer 11555992Swpaul if [ "X$gateway_enable" = X"YES" ]; then 11655992Swpaul echo -n ' IP gateway=YES' 11755992Swpaul sysctl -w net.inet.ip.forwarding=1 >/dev/null 2>&1 118118871Sbrueffer fi 11955992Swpaul 12055992Swpaul if [ "X$forward_sourceroute" = X"YES" ]; then 12155992Swpaul echo -n ' do source routing=YES' 12255992Swpaul sysctl -w net.inet.ip.sourceroute=1 >/dev/null 2>&1 12355992Swpaul fi 12455992Swpaul 12555992Swpaul if [ "X$accept_sourceroute" = X"YES" ]; then 12655992Swpaul echo -n ' accept source routing=YES' 12755992Swpaul sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 2>&1 128166346Sbrueffer fi 12955992Swpaul 130110946Strhodes if [ "X$router_enable" = X"YES" ]; then 13179727Sschweikh echo -n " ${router}"; ${router} ${router_flags} 132117727Shmp fi 13379366Sru 13479366Sru if [ "X$ipxgateway_enable" = X"YES" ]; then 13555992Swpaul echo -n ' IPX gateway=YES' 13655992Swpaul sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 2>&1 13755992Swpaul fi 13855992Swpaul 13955992Swpaul if [ "X$ipxrouted_enable" = X"YES" ]; then 14068854Sru echo -n ' IPXrouted: ' 14155992Swpaul IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 14255992Swpaul fi 14355992Swpaul 14455992Swpaul if [ "X$arpproxy_all" = X"YES" ]; then 145 echo -n ' enabling ARP_PROXY_ALL: ' 146 sysctl -w net.link.ether.inet.proxyall=1 2>&1 147 fi 148 if [ "X$rarpd_enable" = X"YES" ]; then 149 echo -n ' rarpd'; rarpd ${rarpd_flags} 150 fi 151 152 echo '.' 153 network_pass1_done=YES # Let future generations know we made it. 154} 155 156network_pass2() { 157 echo -n 'Doing additional network setup:' 158 if [ "X${named_enable}" = X"YES" ]; then 159 echo -n ' named'; ${named_program-"named"} ${named_flags} 160 fi 161 162 if [ "X${ntpdate_enable}" = X"YES" ]; then 163 echo -n ' ntpdate'; ntpdate ${ntpdate_flags} >/dev/null 2>&1 164 fi 165 166 if [ "X${xntpd_enable}" = X"YES" ]; then 167 echo -n ' xntpd'; xntpd ${xntpd_flags} 168 fi 169 170 if [ "X${timed_enable}" = X"YES" ]; then 171 echo -n ' timed'; timed ${timed_flags} 172 fi 173 174 if [ "X${portmap_enable}" = X"YES" ]; then 175 echo -n ' portmap'; portmap ${portmap_flags} 176 fi 177 178 # Start ypserv if we're an NIS server. 179 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 180 if [ "X${nis_server_enable}" = X"YES" ]; then 181 echo -n ' ypserv'; ypserv ${nis_server_flags} 182 183 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 184 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 185 fi 186 187 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 188 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 189 fi 190 fi 191 192 # Start ypbind if we're an NIS client 193 if [ "X${nis_client_enable}" = X"YES" ]; then 194 echo -n ' ypbind'; ypbind ${nis_client_flags} 195 if [ "X${nis_ypset_enable}" = X"YES" ]; then 196 echo -n ' ypset'; ypset ${nis_ypset_flags} 197 fi 198 fi 199 200 # Start keyserv if we are running Secure RPC 201 if [ "X${keyserv_enable}" = X"YES" ]; then 202 echo -n ' keyserv'; keyserv ${keyserv_flags} 203 fi 204 # Start ypupdated if we are running Secure RPC and we are NIS master 205 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 206 echo -n ' rpc.ypupdated'; rpc.ypupdated 207 fi 208 209 echo '.' 210 network_pass2_done=YES 211} 212 213network_pass3() { 214 echo -n 'Starting final network daemons:' 215 216 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 217 echo -n ' mountd' 218 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 219 mountd_flags="-n" 220 fi 221 mountd ${mountd_flags} 222 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 223 echo -n ' nfsprivport=YES' 224 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 2>&1 225 fi 226 echo -n ' nfsd'; nfsd ${nfs_server_flags} 227 if [ "X$rpc_lockd_enable" = X"YES" ]; then 228 echo -n ' rpc.lockd'; rpc.lockd 229 fi 230 if [ "X$rpc_statd_enable" = X"YES" ]; then 231 echo -n ' rpc.statd'; rpc.statd 232 fi 233 fi 234 235 if [ "X${nfs_client_enable}" = X"YES" ]; then 236 echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 237 fi 238 239 if [ "X${amd_enable}" = X"YES" ]; then 240 echo -n ' amd' 241 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 242 fi 243 244 if [ "X${rwhod_enable}" = X"YES" ]; then 245 echo -n ' rwhod'; rwhod 246 fi 247 248 # Kerberos runs ONLY on the Kerberos server machine 249 if [ "X${kerberos_server_enable}" = X"YES" ]; then 250 if [ "X${kerberos_stash}" = "XYES" ]; then 251 stash_flag=-n 252 else 253 stash_flag= 254 fi 255 echo -n ' kerberos'; \ 256 kerberos ${stash_flags} >> /var/log/kerberos.log & 257 if [ "X${kadmind_server_enable}" = "XYES" ]; then 258 echo -n ' kadmind'; \ 259 (sleep 20; kadmind ${stash_flags} >/dev/null 2>&1 &) & 260 fi 261 unset stash_flag 262 fi 263 264 # IP multicast routing daemon 265 if [ "X${mrouted_enable}" = X"YES" ]; then 266 echo -n ' mrouted'; mrouted ${mrouted_flags} 267 fi 268 echo '.' 269 network_pass3_done=YES 270} 271