1#!/bin/sh - 2#
|
3# $Id: rc.network,v 1.48 1999/07/07 12:49:45 peter Exp $
|
3# $Id: rc.network,v 1.49 1999/07/08 18:56:02 peter Exp $ |
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 "x$nisdomainname" != "xNO" ] ; then 23 domainname $nisdomainname 24 echo -n ' domain' 25 fi 26 echo '.' 27 28 # Initial ATM interface configuration 29 if [ "X${atm_enable}" = X"YES" -a -f /etc/rc.atm ]; then 30 . /etc/rc.atm 31 atm_pass1 32 fi 33 34 # ISDN subsystem startup 35 if [ "X${isdn_enable}" = X"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 [ "x${network_interfaces}" = "xauto" ]; 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 ifconfig ${ifn} ${ifconfig_args}
|
66 # See if we are using DHCP 67 if [ X"${ifconfig_args}" = X"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 # Initialize IP filtering using ipfw 100 echo "" 101 /sbin/ipfw -q flush > /dev/null 2>&1 102 if [ $? = 0 ] ; then 103 firewall_in_kernel=1 104 else 105 firewall_in_kernel=0 106 fi 107 108 if [ $firewall_in_kernel = 0 -a "x$firewall_enable" = "xYES" ] ; then 109 if kldload ipfw; then 110 firewall_in_kernel=1 # module loaded successfully 111 echo "Kernel firewall module loaded." 112 else 113 echo "Warning: firewall kernel module failed to load." 114 fi 115 fi 116 117 # Load the filters if required 118 if [ $firewall_in_kernel = 1 ]; then 119 if [ -z "${firewall_script}" ] ; then 120 firewall_script="/etc/rc.firewall" 121 fi 122 if [ -f ${firewall_script} -a X"$firewall_enable" = X"YES" ]; then 123 . ${firewall_script} 124 echo -n 'Firewall rules loaded, starting divert daemons:' 125 126 # Network Address Translation daemon 127 if [ X"${natd_enable}" = X"YES" -a -n "${natd_interface}" ]; then 128 if echo ${natd_interface} | \ 129 grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then 130 natd_ifarg="-a ${natd_interface}" 131 else 132 natd_ifarg="-n ${natd_interface}" 133 fi 134 echo -n ' natd'; ${natd_program} ${natd_flags} ${natd_ifarg} 135 fi 136 echo '.' 137 else 138 IPFW_DEFAULT=`ipfw l 65535` 139 if [ "$IPFW_DEFAULT" = "65535 deny ip from any to any" ]; then 140 echo -n "Warning: kernel has firewall functionality, " 141 echo "but firewall rules are not enabled." 142 echo " All ip services are disabled." 143 fi 144 fi 145 fi 146 147 # Additional ATM interface configuration 148 if [ -n "${atm_pass1_done}" ]; then 149 atm_pass2 150 fi 151 152 # Configure routing 153 154 if [ "x$defaultrouter" != "xNO" ] ; then 155 static_routes="default ${static_routes}" 156 route_default="default ${defaultrouter}" 157 fi 158 159 # Set up any static routes. This should be done before router discovery. 160 if [ "x${static_routes}" != "x" ]; then 161 for i in ${static_routes}; do 162 eval route_args=\$route_${i} 163 route add ${route_args} 164 done 165 fi 166 167 echo -n 'Additional routing options:' 168 if [ -n "$tcp_extensions" -a "x$tcp_extensions" != "xYES" ] ; then 169 echo -n ' tcp extensions=NO' 170 sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 171 fi 172 173 if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then 174 echo -n ' log_in_vain=YES' 175 sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 176 sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 177 fi 178 179 if [ X"$icmp_bmcastecho" = X"YES" ]; then 180 echo -n ' broadcast ping responses=YES' 181 sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 182 fi 183 184 if [ "X$gateway_enable" = X"YES" ]; then 185 echo -n ' IP gateway=YES' 186 sysctl -w net.inet.ip.forwarding=1 >/dev/null 187 fi 188 189 if [ "X$forward_sourceroute" = X"YES" ]; then 190 echo -n ' do source routing=YES' 191 sysctl -w net.inet.ip.sourceroute=1 >/dev/null 192 fi 193 194 if [ "X$accept_sourceroute" = X"YES" ]; then 195 echo -n ' accept source routing=YES' 196 sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null 197 fi 198 199 if [ "X$tcp_keepalive" = X"YES" ]; then 200 echo -n ' TCP keepalive=YES' 201 sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null 202 fi 203 204 if [ "X$ipxgateway_enable" = X"YES" ]; then 205 echo -n ' IPX gateway=YES' 206 sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null 207 fi 208 209 if [ "X$arpproxy_all" = X"YES" ]; then 210 echo -n ' ARP proxyall=YES' 211 sysctl -w net.link.ether.inet.proxyall=1 >/dev/null 212 fi 213 echo '.' 214 215 echo -n 'routing daemons:' 216 if [ "X$router_enable" = X"YES" ]; then 217 echo -n " ${router}"; ${router} ${router_flags} 218 fi 219 220 if [ "X$ipxrouted_enable" = X"YES" ]; then 221 echo -n ' IPXrouted' 222 IPXrouted ${ipxrouted_flags} > /dev/null 2>&1 223 fi 224 225 if [ "X${mrouted_enable}" = X"YES" ]; then 226 echo -n ' mrouted'; mrouted ${mrouted_flags} 227 fi 228 229 if [ "X$rarpd_enable" = X"YES" ]; then 230 echo -n ' rarpd'; rarpd ${rarpd_flags} 231 fi 232 echo '.' 233 network_pass1_done=YES # Let future generations know we made it. 234} 235 236network_pass2() { 237 echo -n 'Doing additional network setup:' 238 if [ "X${named_enable}" = X"YES" ]; then 239 echo -n ' named'; ${named_program-"named"} ${named_flags} 240 fi 241 242 if [ "X${ntpdate_enable}" = X"YES" ]; then 243 echo -n ' ntpdate'; ${ntpdate_program} ${ntpdate_flags} >/dev/null 2>&1 244 fi 245 246 if [ "X${xntpd_enable}" = X"YES" ]; then 247 echo -n ' xntpd'; ${xntpd_program} ${xntpd_flags} 248 fi 249 250 if [ "X${timed_enable}" = X"YES" ]; then 251 echo -n ' timed'; timed ${timed_flags} 252 fi 253 254 if [ "X${portmap_enable}" = X"YES" ]; then 255 echo -n ' portmap'; ${portmap_program} ${portmap_flags} 256 fi 257 258 # Start ypserv if we're an NIS server. 259 # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server. 260 if [ "X${nis_server_enable}" = X"YES" ]; then 261 echo -n ' ypserv'; ypserv ${nis_server_flags} 262 263 if [ "X${nis_ypxfrd_enable}" = X"YES" ]; then 264 echo -n ' rpc.ypxfrd'; rpc.ypxfrd ${nis_ypxfrd_flags} 265 fi 266 267 if [ "X${nis_yppasswdd_enable}" = X"YES" ]; then 268 echo -n ' rpc.yppasswdd'; rpc.yppasswdd ${nis_yppasswdd_flags} 269 fi 270 fi 271 272 # Start ypbind if we're an NIS client 273 if [ "X${nis_client_enable}" = X"YES" ]; then 274 echo -n ' ypbind'; ypbind ${nis_client_flags} 275 if [ "X${nis_ypset_enable}" = X"YES" ]; then 276 echo -n ' ypset'; ypset ${nis_ypset_flags} 277 fi 278 fi 279 280 # Start keyserv if we are running Secure RPC 281 if [ "X${keyserv_enable}" = X"YES" ]; then 282 echo -n ' keyserv'; keyserv ${keyserv_flags} 283 fi 284 # Start ypupdated if we are running Secure RPC and we are NIS master 285 if [ "X$rpc_ypupdated_enable" = X"YES" ]; then 286 echo -n ' rpc.ypupdated'; rpc.ypupdated 287 fi 288 289 # Start ATM daemons 290 if [ -n "${atm_pass2_done}" ]; then 291 atm_pass3 292 fi 293 294 echo '.' 295 network_pass2_done=YES 296} 297 298network_pass3() { 299 echo -n 'Starting final network daemons:' 300 301 if [ "X${nfs_server_enable}" = X"YES" -a -r /etc/exports ]; then 302 echo -n ' mountd' 303 if [ "X${weak_mountd_authentication}" = X"YES" ]; then 304 mountd_flags="-n" 305 fi 306 mountd ${mountd_flags} 307 if [ "X${nfs_reserved_port_only}" = X"YES" ]; then 308 echo -n ' NFS on reserved port only=YES' 309 sysctl -w vfs.nfs.nfs_privport=1 >/dev/null 310 fi 311 echo -n ' nfsd'; nfsd ${nfs_server_flags} 312 if [ "X$rpc_lockd_enable" = X"YES" ]; then 313 echo -n ' rpc.lockd'; rpc.lockd 314 fi 315 if [ "X$rpc_statd_enable" = X"YES" ]; then 316 echo -n ' rpc.statd'; rpc.statd 317 fi 318 fi 319 320 if [ "X${nfs_client_enable}" = X"YES" ]; then 321 echo -n ' nfsiod'; nfsiod ${nfs_client_flags} 322 if [ "X${nfs_access_cache}" != X ]; then 323 echo -n " NFS access cache time=${nfs_access_cache}" 324 sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \ 325 >/dev/null 326 fi 327 fi 328 329 if [ "X${amd_enable}" = X"YES" ]; then 330 echo -n ' amd' 331 if [ "X${amd_map_program}" != X"NO" ]; then 332 amd_flags="${amd_flags} `eval ${amd_map_program}`" 333 fi 334 if [ -n "$amd_flags" ] 335 then 336 amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null 337 else 338 amd 2> /dev/null 339 fi 340 fi 341 342 if [ "X${rwhod_enable}" = X"YES" ]; then 343 echo -n ' rwhod'; rwhod ${rwhod_flags} 344 fi 345 346 # Kerberos runs ONLY on the Kerberos server machine 347 if [ "X${kerberos_server_enable}" = X"YES" ]; then 348 if [ "X${kerberos_stash}" = "XYES" ]; then 349 stash_flag=-n 350 else 351 stash_flag= 352 fi 353 echo -n ' kerberos'; \ 354 kerberos ${stash_flag} >> /var/log/kerberos.log & 355 if [ "X${kadmind_server_enable}" = "XYES" ]; then 356 echo -n ' kadmind'; \ 357 (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) & 358 fi 359 unset stash_flag 360 fi 361 362 echo '.' 363 network_pass3_done=YES 364}
|