defaultroute revision 50472
1#!/bin/sh - 2# 3# $FreeBSD: head/etc/rc.d/routing 50472 1999-08-27 23:37:10Z peter $ 4# From: @(#)netstart 5.9 (Berkeley) 3/30/91 5 6# Note that almost all the user-configurable behavior is no longer in 7# this file, but rather in /etc/rc.conf. Please check that file 8# first before contemplating any changes here. If you do need to change 9# this file for some reason, we would like to know about it. 10 11# First pass startup stuff. 12 13network_pass1() { 14 echo -n 'Doing initial network setup:' 15 # Set the host name if it is not already set 16 if [ -z "`hostname -s`" ] ; then 17 hostname ${hostname} 18 echo -n ' hostname' 19 fi 20 21 # Set the domainname if we're using NIS 22 if [ -n "${nisdomainname}" -a "${nisdomainname}" != "NO" ] ; then 23 domainname ${nisdomainname} 24 echo -n ' domain' 25 fi 26 echo '.' 27 28 # Initial ATM interface configuration 29 if [ "${atm_enable}" = "YES" -a -f /etc/rc.atm ]; then 30 . /etc/rc.atm 31 atm_pass1 32 fi 33 34 # ISDN subsystem startup 35 if [ "${isdn_enable}" = "YES" -a -f /etc/rc.isdn ]; then 36 . /etc/rc.isdn 37 fi 38 39 # Special options for sppp(4) interfaces go here. These need 40 # to go _before_ the general ifconfig section, since in the case 41 # of hardwired (no link1 flag) but required authentication, you 42 # cannot pass auth parameters down to the already running interface. 43 for ifn in ${sppp_interfaces}; do 44 eval spppcontrol_args=\$spppconfig_${ifn} 45 if [ -n "${spppcontrol_args}" ] ; then 46 # The auth secrets might contain spaces; in order 47 # to retain the quotation, we need to eval them 48 # here. 49 eval spppcontrol ${ifn} ${spppcontrol_args} 50 fi 51 done 52 53 # Set up all the network interfaces, calling startup scripts if needed 54 if [ "${network_interfaces}" = "auto" ]; then 55 network_interfaces="`ifconfig -l`" 56 fi 57 for ifn in ${network_interfaces}; do 58 showstat=false 59 if [ -e /etc/start_if.${ifn} ]; then 60 . /etc/start_if.${ifn} 61 showstat=true 62 fi 63 # Do the primary ifconfig if specified 64 eval ifconfig_args=\$ifconfig_${ifn} 65 if [ -n "${ifconfig_args}" ] ; then 66 # See if we are using DHCP 67 if [ "${ifconfig_args}" = "DHCP" ]; then 68 ${dhcp_program} ${dhcp_flags} ${ifn} 69 else 70 ifconfig ${ifn} ${ifconfig_args} 71 fi 72 showstat=true 73 fi 74 # Check to see if aliases need to be added 75 alias=0 76 while : 77 do 78 eval ifconfig_args=\$ifconfig_${ifn}_alias${alias} 79 if [ -n "${ifconfig_args}" ]; then 80 ifconfig ${ifn} ${ifconfig_args} alias 81 showstat=true 82 alias=`expr ${alias} + 1` 83 else 84 break; 85 fi 86 done 87 # Do ipx address if specified 88 eval ifconfig_args=\$ifconfig_${ifn}_ipx 89 if [ -n "${ifconfig_args}" ]; then 90 ifconfig ${ifn} ${ifconfig_args} 91 showstat=true 92 fi 93 if [ "${showstat}" = "true" ] 94 then 95 ifconfig ${ifn} 96 fi 97 done 98 99 # Warm up user ppp if required, must happen before natd. 100 if [ "${ppp_enable}" = "YES" ]; then 101 # Establish ppp mode. 102 if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \ 103 -a "${ppp_mode}" != "dedicated" ]; then \ 104 ppp_mode="auto"; 105 fi 106 ppp_command="-${ppp_mode} "; 107 108 # Switch on alias mode? 109 if [ "${ppp_nat}" = "YES" ]; then 110 ppp_command="${ppp_command} -nat"; 111 fi 112 113 echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile} 114 fi 115 116 # Initialize IP filtering using ipfw 117 echo "" 118 /sbin/ipfw -q flush > /dev/null 2>&1 119 if [ $? = 0 ] ; then 120 firewall_in_kernel=1 121 else 122 firewall_in_kernel=0 123 fi 124 125 if [ ${firewall_in_kernel} = 0 -a "${firewall_enable}" = "YES" ] ; then 126 if kldload ipfw; then 127 firewall_in_kernel=1 # module loaded successfully 128 echo "Kernel firewall module loaded." 129 else 130 echo "Warning: firewall kernel module failed to load." 131 fi 132 fi 133 134 # Load the filters if required 135 if [ ${firewall_in_kernel} = 1 ]; then 136 if [ -z "${firewall_script}" ] ; then 137 firewall_script="/etc/rc.firewall" 138 fi 139 if [ -f ${firewall_script} -a "${firewall_enable}" = "YES" ]; then 140 . ${firewall_script} 141 echo -n 'Firewall rules loaded, starting divert daemons:' 142 143 # Network Address Translation daemon 144 if [ "${natd_enable}" = "YES" -a -n "${natd_interface}" ]; then 145 if echo ${natd_interface} | \ 146 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 147 natd_ifarg="-a ${natd_interface}" 148 else 149 natd_ifarg="-n ${natd_interface}" 150 fi 151 echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 152 fi 153 echo '.' 154 else 155 IPFW_DEFAULT=`ipfw l 65535` 156 if [ "${IPFW_DEFAULT}" = "65535 deny ip from any to any" ]; then 157 echo -n "Warning: kernel has firewall functionality, " 158 echo "but firewall rules are not enabled." 159 echo " All ip services are disabled." 160 fi 161 fi 162 fi 163 164 # Additional ATM interface configuration 165 if [ -n "${atm_pass1_done}" ]; then 166 atm_pass2 167 fi 168 169 # Configure routing 170 171 if [ "${defaultrouter}" != "NO" ] ; then 172 static_routes="default ${static_routes}" 173 route_default="default ${defaultrouter}" 174 fi 175 176 # Set up any static routes. This should be done before router discovery. 177 if [ -n "${static_routes}" ]; then 178 for i in ${static_routes}; do 179 eval route_args=\$route_${i} 180 route add ${route_args} 181 done 182 fi 183 184 echo -n 'Additional routing options:' 185 if [ -n "${tcp_extensions}" -a "${tcp_extensions}" != "YES" ] ; then 186 echo -n ' tcp extensions=NO' 187 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 188 fi 189 190 if [ -n "${log_in_vain}" -a "${log_in_vain}" != "NO" ] ; then 191 echo -n ' log_in_vain=YES' 192 sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 193 sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 194 fi 195 196 if [ "${icmp_bmcastecho}" = "YES" ]; then 197 echo -n ' broadcast ping responses=YES' 198 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 199 fi 200 201 if [ "${icmp_drop_redirect}" = "YES" ]; then 202 echo -n ' ignore ICMP redirect=YES' 203 sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null 204 fi 205 206 if [ "${icmp_log_redirect}" = "YES" ]; then 207 echo -n ' log ICMP redirect=YES' 208 sysctl -w net.inet.icmp.log_redirect=1 >/dev/null 209 fi 210 211 if [ "${gateway_enable}" = "YES" ]; then 212 echo -n ' IP gateway=YES' 213 sysctl -w net.inet.ip.forwarding=1 >/dev/null 214 fi 215 216 if [ "${forward_sourceroute}" = "YES" ]; then 217 echo -n ' do source routing=YES' 218 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 219 fi 220 221 if [ "${accept_sourceroute}" = "YES" ]; then 222 echo -n ' accept source routing=YES' 223 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 224 fi 225 226 if [ "${tcp_keepalive}" = "YES" ]; then 227 echo -n ' TCP keepalive=YES' 228 sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null 229 fi 230 231 if [ "${ipxgateway_enable}" = "YES" ]; then 232 echo -n ' IPX gateway=YES' 233 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 234 fi 235 236 if [ "${arpproxy_all}" = "YES" ]; then 237 echo -n ' ARP proxyall=YES' 238 sysctl -w net.link.ether.inet.proxyall=1 >/dev/null 239 fi 240 echo '.' 241 242 echo -n 'routing daemons:' 243 if [ "${router_enable}" = "YES" ]; then 244 echo -n " ${router}"; ${router} ${router_flags} 245 fi 246 247 if [ "${ipxrouted_enable}" = "YES" ]; then 248 echo -n ' IPXrouted' 249 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 250 fi 251 252 if [ "${mrouted_enable}" = "YES" ]; then 253 echo -n ' mrouted'; mrouted ${mrouted_flags} 254 fi 255 256 if [ "${rarpd_enable}" = "YES" ]; then 257 echo -n ' rarpd'; rarpd ${rarpd_flags} 258 fi 259 echo '.' 260 network_pass1_done=YES # Let future generations know we made it. 261} 262 263network_pass2() { 264 echo -n 'Doing additional network setup:' 265 if [ "${named_enable}" = "YES" ]; then 266 echo -n ' named'; ${named_program-"named"} ${named_flags} 267 fi 268 269 if [ "${ntpdate_enable}" = "YES" ]; then 270 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 271 fi 272 273 if [ "${xntpd_enable}" = "YES" ]; then 274 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 275 fi 276 277 if [ "${timed_enable}" = "YES" ]; then 278 echo -n ' timed'; timed ${timed_flags} 279 fi 280 281 if [ "${portmap_enable}" = "YES" ]; then 282 echo -n ' portmap'; ${portmap_program} ${portmap_flags} 283 fi 284 285 # Start ypserv if we're an NIS server. 286 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 287 if [ "${nis_server_enable}" = "YES" ]; then 288 echo -n ' ypserv'; ypserv ${nis_server_flags} 289 290 if [ "${nis_ypxfrd_enable}" = "YES" ]; then 291 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 292 fi 293 294 if [ "${nis_yppasswdd_enable}" = "YES" ]; then 295 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 296 fi 297 fi 298 299 # Start ypbind if we're an NIS client 300 if [ "${nis_client_enable}" = "YES" ]; then 301 echo -n ' ypbind'; ypbind ${nis_client_flags} 302 if [ "${nis_ypset_enable}" = "YES" ]; then 303 echo -n ' ypset'; ypset ${nis_ypset_flags} 304 fi 305 fi 306 307 # Start keyserv if we are running Secure RPC 308 if [ "${keyserv_enable}" = "YES" ]; then 309 echo -n ' keyserv'; keyserv ${keyserv_flags} 310 fi 311 # Start ypupdated if we are running Secure RPC and we are NIS master 312 if [ "${rpc_ypupdated_enable}" = "YES" ]; then 313 echo -n ' rpc.ypupdated'; rpc.ypupdated 314 fi 315 316 # Start ATM daemons 317 if [ -n "${atm_pass2_done}" ]; then 318 atm_pass3 319 fi 320 321 echo '.' 322 network_pass2_done=YES 323} 324 325network_pass3() { 326 echo -n 'Starting final network daemons:' 327 328 if [ "${nfs_server_enable}" = "YES" -a -r /etc/exports ]; then 329 echo -n ' mountd' 330 if [ "${weak_mountd_authentication}" = "YES" ]; then 331 mountd_flags="-n" 332 fi 333 mountd ${mountd_flags} 334 if [ "${nfs_reserved_port_only}" = "YES" ]; then 335 echo -n ' NFS on reserved port only=YES' 336 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 337 fi 338 echo -n ' nfsd'; nfsd ${nfs_server_flags} 339 if [ "${rpc_lockd_enable}" = "YES" ]; then 340 echo -n ' rpc.lockd'; rpc.lockd 341 fi 342 if [ "${rpc_statd_enable}" = "YES" ]; then 343 echo -n ' rpc.statd'; rpc.statd 344 fi 345 fi 346 347 if [ "${nfs_client_enable}" = "YES" ]; then 348 echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 349 if [ "${nfs_access_cache}" != "X" ]; then 350 echo -n " NFS access cache time=${nfs_access_cache}" 351 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 352 >/dev/null 353 fi 354 fi 355 356 if [ "${amd_enable}" = "YES" ]; then 357 echo -n ' amd' 358 if [ "${amd_map_program}" != "NO" ]; then 359 amd_flags="${amd_flags} `eval ${amd_map_program}`" 360 fi 361 if [ -n "${amd_flags}" ] 362 then 363 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 364 else 365 amd 2> /dev/null 366 fi 367 fi 368 369 if [ "${rwhod_enable}" = "YES" ]; then 370 echo -n ' rwhod'; rwhod ${rwhod_flags} 371 fi 372 373 # Kerberos runs ONLY on the Kerberos server machine 374 if [ "${kerberos_server_enable}" = "YES" ]; then 375 if [ "${kerberos_stash}" = "YES" ]; then 376 stash_flag=-n 377 else 378 stash_flag= 379 fi 380 echo -n ' kerberos'; \ 381 kerberos ${stash_flag} >> /var/log/kerberos.log & 382 if [ "${kadmind_server_enable}" = "YES" ]; then 383 echo -n ' kadmind'; \ 384 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 385 fi 386 unset stash_flag 387 fi 388 389 echo '.' 390 network_pass3_done=YES 391} 392