Home | History | Annotate | Line # | Download | only in rc.d
network revision 1.59
      1   1.1     lukem #!/bin/sh
      2   1.1     lukem #
      3  1.59    cegger # $NetBSD: network,v 1.59 2009/09/08 08:56:33 cegger Exp $
      4   1.1     lukem #
      5   1.1     lukem 
      6   1.1     lukem # PROVIDE: network
      7  1.19     lukem # REQUIRE: ipfilter ipsec mountcritlocal root tty sysctl
      8  1.34   thorpej # BEFORE:  NETWORKING
      9   1.1     lukem 
     10  1.45   mycroft $_rc_subr_loaded . /etc/rc.subr
     11   1.1     lukem 
     12   1.1     lukem name="network"
     13   1.1     lukem start_cmd="network_start"
     14  1.14     lukem stop_cmd="network_stop"
     15  1.59    cegger fstab_file="/etc/fstab"
     16   1.1     lukem 
     17  1.54       apb nl='
     18  1.54       apb ' # a newline
     19  1.54       apb 
     20   1.1     lukem network_start()
     21   1.1     lukem {
     22   1.1     lukem 	# set hostname, turn on network
     23   1.1     lukem 	#
     24   1.1     lukem 	echo "Starting network."
     25   1.1     lukem 
     26   1.1     lukem 	# If $hostname is set, use it for my Internet name,
     27   1.1     lukem 	# otherwise use /etc/myname
     28   1.1     lukem 	#
     29  1.20  nisimura 	if [ -z "$hostname" ] && [ -f /etc/myname ]; then
     30  1.46  christos 		hostname=$(cat /etc/myname)
     31   1.1     lukem 	fi
     32   1.1     lukem 	if [ -n "$hostname" ]; then
     33   1.1     lukem 		echo "Hostname: $hostname"
     34   1.1     lukem 		hostname $hostname
     35   1.1     lukem 	else
     36   1.8   thorpej 		# Don't warn about it if we're going to run
     37   1.8   thorpej 		# DHCP later, as we will probably get the
     38   1.8   thorpej 		# hostname at that time.
     39   1.8   thorpej 		#
     40  1.58       roy 		if ! checkyesno dhclient && ! checkyesno dhcpcd && \
     41  1.58       roy 			[ -z "$(hostname)" ]
     42  1.58       roy 		then
     43   1.8   thorpej 			warn "\$hostname not set."
     44   1.8   thorpej 		fi
     45   1.1     lukem 	fi
     46   1.1     lukem 
     47   1.1     lukem 	# Check $domainname first, then /etc/defaultdomain,
     48   1.1     lukem 	# for NIS/YP domain name
     49   1.1     lukem 	#
     50  1.20  nisimura 	if [ -z "$domainname" ] && [ -f /etc/defaultdomain ]; then
     51  1.46  christos 		domainname=$(cat /etc/defaultdomain)
     52   1.1     lukem 	fi
     53   1.1     lukem 	if [ -n "$domainname" ]; then
     54   1.1     lukem 		echo "NIS domainname: $domainname"
     55   1.1     lukem 		domainname $domainname
     56   1.1     lukem 	fi
     57   1.1     lukem 
     58  1.59    cegger 	# Do not flush routes if root file system is nfs mounted in /etc/fstab,
     59  1.59    cegger 	# or the nfs server is unreachable if it is in a different subnet,
     60  1.59    cegger 	# otherwise.
     61  1.59    cegger 	while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
     62  1.59    cegger 	do
     63  1.59    cegger 		case "${fs_spec}:${fs_file}:${fs_passno}" in
     64  1.59    cegger 		\#*|'':*)
     65  1.59    cegger 			continue # skip comment or blank line
     66  1.59    cegger 			;;
     67  1.59    cegger 		*:/:*)  case "${fs_spec}" in
     68  1.59    cegger 			*:*)
     69  1.59    cegger 				echo "Not flushing routes. /: nfs mounted"
     70  1.59    cegger 				flushroutes="NO"
     71  1.59    cegger 				;;
     72  1.59    cegger 			esac
     73  1.59    cegger 			;;
     74  1.59    cegger 		esac
     75  1.59    cegger 	done <"${fstab_file}"
     76  1.59    cegger 
     77  1.59    cegger 
     78   1.1     lukem 	# Flush all routes just to make sure it is clean
     79   1.1     lukem 	if checkyesno flushroutes; then
     80  1.53      reed 		/sbin/route -qn flush
     81   1.1     lukem 	fi
     82   1.1     lukem 
     83   1.1     lukem 	# Set the address for the first loopback interface, so that the
     84   1.1     lukem 	# auto-route from a newly configured interface's address to lo0
     85   1.1     lukem 	# works correctly.
     86   1.1     lukem 	#
     87  1.32     lukem 	# NOTE: obscure networking problems will occur if lo0 isn't configured.
     88   1.1     lukem 	#
     89  1.53      reed 	/sbin/ifconfig lo0 inet 127.0.0.1
     90  1.10    itojun 
     91  1.31    itojun 	# According to RFC1122, 127.0.0.0/8 must not leave the node.
     92  1.10    itojun 	#
     93  1.53      reed 	/sbin/route -q add -inet 127.0.0.0 -netmask 0xff000000 127.0.0.1 -reject
     94   1.1     lukem 
     95  1.30    itojun 	# IPv6 routing setups, and host/router mode selection.
     96  1.30    itojun 	#
     97  1.53      reed 	if /sbin/ifconfig lo0 inet6 >/dev/null 2>&1; then
     98  1.30    itojun 		# We have IPv6 support in kernel.
     99  1.30    itojun 
    100  1.30    itojun 		# disallow link-local unicast dest without outgoing scope
    101  1.30    itojun 		# identifiers.
    102  1.30    itojun 		#
    103  1.53      reed 		/sbin/route -q add -inet6 fe80:: -prefixlen 10 ::1 -reject
    104  1.30    itojun 
    105  1.50    rpaulo 		# disallow the use of the RFC3849 documentation address
    106  1.50    rpaulo 		#
    107  1.53      reed 		/sbin/route -q add -inet6 2001:db8:: -prefixlen 32 ::1 -reject
    108  1.50    rpaulo 
    109  1.50    rpaulo 		# IPv6 site-local scoped address prefix (fec0::/10)
    110  1.50    rpaulo 		# has been deprecated by RFC3879.
    111  1.30    itojun 		#
    112  1.50    rpaulo 		if [ -n "$ip6sitelocal" ]; then
    113  1.50    rpaulo 			warn "\$ip6sitelocal is no longer valid"
    114  1.30    itojun 		fi
    115  1.30    itojun 
    116  1.30    itojun 		# disallow "internal" addresses to appear on the wire.
    117  1.30    itojun 		#
    118  1.53      reed 		/sbin/route -q add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
    119  1.30    itojun 
    120  1.30    itojun 		# disallow packets to malicious IPv4 compatible prefix
    121  1.30    itojun 		#
    122  1.53      reed 		/sbin/route -q add -inet6 ::224.0.0.0 -prefixlen 100 ::1 -reject
    123  1.53      reed 		/sbin/route -q add -inet6 ::127.0.0.0 -prefixlen 104 ::1 -reject
    124  1.53      reed 		/sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 104 ::1 -reject
    125  1.53      reed 		/sbin/route -q add -inet6 ::255.0.0.0 -prefixlen 104 ::1 -reject
    126  1.30    itojun 
    127  1.30    itojun 		# disallow packets to malicious 6to4 prefix
    128  1.30    itojun 		#
    129  1.53      reed 		/sbin/route -q add -inet6 2002:e000:: -prefixlen 20 ::1 -reject
    130  1.53      reed 		/sbin/route -q add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject
    131  1.53      reed 		/sbin/route -q add -inet6 2002:0000:: -prefixlen 24 ::1 -reject
    132  1.53      reed 		/sbin/route -q add -inet6 2002:ff00:: -prefixlen 24 ::1 -reject
    133  1.30    itojun 
    134  1.30    itojun 		# Completely disallow packets to IPv4 compatible prefix.
    135  1.30    itojun 		# This may conflict with RFC1933 under following circumstances:
    136  1.30    itojun 		# (1) An IPv6-only KAME node tries to originate packets to IPv4
    137  1.51      reed 		#     compatible destination.  The KAME node has no IPv4
    138  1.30    itojun 		#     compatible support.  Under RFC1933, it should transmit
    139  1.30    itojun 		#     native IPv6 packets toward IPv4 compatible destination,
    140  1.30    itojun 		#     hoping it would reach a router that forwards the packet
    141  1.30    itojun 		#     toward auto-tunnel interface.
    142  1.30    itojun 		# (2) An IPv6-only node originates a packet to IPv4 compatible
    143  1.30    itojun 		#     destination.  A KAME node is acting as an IPv6 router, and
    144  1.30    itojun 		#     asked to forward it.
    145  1.30    itojun 		# Due to rare use of IPv4 compatible address, and security
    146  1.30    itojun 		# issues with it, we disable it by default.
    147  1.30    itojun 		#
    148  1.53      reed 		/sbin/route -q add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
    149  1.30    itojun 
    150  1.53      reed 		/sbin/sysctl -qw net.inet6.ip6.forwarding=0
    151  1.53      reed 		/sbin/sysctl -qw net.inet6.ip6.accept_rtadv=0
    152  1.30    itojun 
    153  1.30    itojun 		case $ip6mode in
    154  1.30    itojun 		router)
    155  1.30    itojun 			echo 'IPv6 mode: router'
    156  1.53      reed 			/sbin/sysctl -qw net.inet6.ip6.forwarding=1
    157  1.50    rpaulo 
    158  1.50    rpaulo 			# disallow unique-local unicast forwarding without
    159  1.50    rpaulo 			# explicit configuration.
    160  1.50    rpaulo 			if ! checkyesno ip6uniquelocal; then
    161  1.53      reed 				/sbin/route -q add -inet6 fc00:: -prefixlen 7 \
    162  1.50    rpaulo 				    ::1 -reject
    163  1.50    rpaulo 			fi
    164  1.30    itojun 			;;
    165  1.30    itojun 
    166  1.30    itojun 		autohost)
    167  1.30    itojun 			echo 'IPv6 mode: autoconfigured host'
    168  1.53      reed 			/sbin/sysctl -qw net.inet6.ip6.accept_rtadv=1
    169  1.30    itojun 			;;
    170  1.30    itojun 
    171  1.30    itojun 		host)	
    172  1.30    itojun 			echo 'IPv6 mode: host'
    173  1.30    itojun 			;;
    174  1.30    itojun 
    175  1.36     lukem 		*)	warn "invalid \$ip6mode value "\"$ip6mode\"
    176  1.30    itojun 			;;
    177  1.30    itojun 
    178  1.30    itojun 		esac
    179  1.30    itojun 	fi
    180  1.30    itojun 
    181   1.1     lukem 	# Configure all of the network interfaces listed in $net_interfaces;
    182   1.1     lukem 	# if $auto_ifconfig is YES, grab all interfaces from ifconfig.
    183   1.1     lukem 	# In the following, "xxN" stands in for interface names, like "le0".
    184  1.54       apb 	#
    185  1.54       apb 	# For any interfaces that has an $ifconfig_xxN variable
    186  1.54       apb 	# associated, we break it into lines using ';' as a separator,
    187  1.54       apb 	# then process it just like the contents of an /etc/ifconfig.xxN
    188  1.54       apb 	# file.
    189  1.54       apb 	#
    190  1.54       apb 	# For each line from the $ifconfig_xxN variable or the
    191  1.54       apb 	# /etc/ifconfig.xxN file, we ignore comments and blank lines,
    192  1.54       apb 	# treat lines beginning with "!" as commands to execute, treat
    193  1.54       apb 	# "dhcp" as a special case to invoke dhcpcd, and for any other
    194  1.54       apb 	# line we run "ifconfig xxN", using each line of the file as the
    195  1.54       apb 	# arguments for a separate "ifconfig" invocation.
    196   1.1     lukem 	#
    197   1.1     lukem 	# In order to configure an interface reasonably, you at the very least
    198   1.1     lukem 	# need to specify "[addr_family] [hostname]" (e.g "inet my.domain.org"),
    199   1.1     lukem 	# and probably a netmask (as in "netmask 0xffffffe0"). You will
    200   1.1     lukem 	# frequently need to specify a media type, as in "media UTP", for
    201   1.1     lukem 	# interface cards with multiple media connections that do not
    202   1.1     lukem 	# autoconfigure. See the ifconfig manual page for details.
    203   1.1     lukem 	#
    204   1.1     lukem 	# Note that /etc/ifconfig.xxN takes multiple lines.  The following
    205   1.1     lukem 	# configuration is possible:
    206   1.1     lukem 	#	inet 10.1.1.1 netmask 0xffffff00
    207   1.1     lukem 	#	inet 10.1.1.2 netmask 0xffffff00 alias
    208  1.50    rpaulo 	#	inet6 2001:db8::1 prefixlen 64 alias
    209   1.1     lukem 	#
    210  1.29    itojun 	# You can put shell script fragment into /etc/ifconfig.xxN by
    211  1.29    itojun 	# starting a line with "!".  Refer to ifconfig.if(5) for details.
    212  1.29    itojun 	#
    213   1.1     lukem 	if [ "$net_interfaces" != NO ]; then
    214   1.1     lukem 		if checkyesno auto_ifconfig; then
    215  1.53      reed 			tmp=$(/sbin/ifconfig -l)
    216  1.53      reed 			for cloner in $(/sbin/ifconfig -C 2>/dev/null); do
    217  1.25       wiz 				for int in /etc/ifconfig.${cloner}[0-9]*; do
    218  1.23  nisimura 					[ ! -f $int ] && break
    219  1.21     lukem 					tmp="$tmp ${int##*.}"
    220  1.15   thorpej 				done
    221  1.15   thorpej 			done
    222   1.1     lukem 		else
    223   1.1     lukem 			tmp="$net_interfaces"
    224   1.1     lukem 		fi
    225   1.1     lukem 		echo -n 'Configuring network interfaces:'
    226   1.1     lukem 		for int in $tmp; do
    227  1.54       apb 			eval argslist=\$ifconfig_$int
    228  1.54       apb 
    229  1.54       apb 			# Skip interfaces that do not have explicit
    230  1.54       apb 			# configuration information.  If auto_ifconfig is
    231  1.54       apb 			# false then also warn about such interfaces.
    232  1.54       apb 			#
    233  1.54       apb 			if [ -z "$argslist" ] && ! [ -f /etc/ifconfig.$int ]
    234  1.54       apb 			then
    235   1.1     lukem 				if ! checkyesno auto_ifconfig; then
    236   1.1     lukem 					echo
    237   1.1     lukem 					warn \
    238   1.1     lukem 			"/etc/ifconfig.$int missing and ifconfig_$int not set;"
    239   1.1     lukem 					warn "interface $int not configured."
    240   1.1     lukem 				fi
    241   1.1     lukem 				continue
    242   1.1     lukem 			fi
    243  1.54       apb 
    244  1.54       apb 			echo -n " $int"
    245  1.54       apb 
    246  1.54       apb 			# Create the interface if necessary.
    247  1.54       apb 			# If the interface did not exist before,
    248  1.54       apb 			# then also resync ipf(4).
    249  1.54       apb 			#
    250  1.54       apb 			if /sbin/ifconfig $int create 2>/dev/null && \
    251  1.54       apb 			   checkyesno ipfilter; then
    252  1.54       apb 				/sbin/ipf -y >/dev/null
    253  1.54       apb 			fi
    254  1.54       apb 
    255  1.54       apb 			# If $ifconfig_xxN is empty, then use
    256  1.54       apb 			# /etc/ifconfig.xxN, which we know exists due to
    257  1.54       apb 			# an earlier test.
    258  1.54       apb 			#
    259  1.54       apb 			# If $ifconfig_xxN is non-empty and contains a
    260  1.54       apb 			# newline, then just use it as is.  (This allows
    261  1.54       apb 			# semicolons through unmolested.)
    262  1.54       apb 			#
    263  1.54       apb 			# If $ifconfig_xxN is non-empty and does not
    264  1.54       apb 			# contain a newline, then convert all semicolons
    265  1.54       apb 			# to newlines.
    266  1.54       apb 			#
    267  1.54       apb 			case "$argslist" in
    268  1.54       apb 			'')
    269  1.54       apb 				cat /etc/ifconfig.$int
    270  1.54       apb 				;;
    271  1.54       apb 			*"${nl}"*)
    272  1.54       apb 				echo "$argslist"
    273  1.54       apb 				;;
    274  1.54       apb 			*)
    275  1.54       apb 				(
    276  1.54       apb 					set -o noglob
    277  1.54       apb 					IFS=';'; set -- $argslist
    278  1.54       apb 					#echo >&2 "[$#] [$1] [$2] [$3] [$4]"
    279  1.54       apb 					IFS="$nl"; echo "$*"
    280  1.54       apb 				)
    281  1.54       apb 				;;
    282  1.54       apb 			esac |
    283  1.54       apb 			while read -r args; do
    284  1.54       apb 				case "$args" in
    285  1.54       apb 				''|"#"*|create)
    286  1.54       apb 					;;
    287  1.54       apb 				"!"*)
    288  1.54       apb 					# Run arbitrary command in a subshell.
    289  1.54       apb 					( eval "${args#*!}" )
    290  1.54       apb 					;;
    291  1.54       apb 				dhcp)
    292  1.58       roy 					if ! checkyesno dhcpcd; then
    293  1.58       roy 						/sbin/dhcpcd -n \
    294  1.58       roy 							${dhcpcd_flags} $int
    295  1.58       roy 					fi
    296  1.54       apb 					;;
    297  1.54       apb 				*)
    298  1.54       apb 					# Pass args to ifconfig.  Note
    299  1.54       apb 					# that args may contain embedded
    300  1.54       apb 					# shell metacharacters, such as
    301  1.57  christos 					# "ssid 'foo;*>bar'". We eval
    302  1.57  christos 					# one more time so that things
    303  1.57  christos 					# like ssid "Columbia University" work.
    304  1.54       apb 					(
    305  1.54       apb 						set -o noglob
    306  1.57  christos 						eval set -- $args
    307  1.54       apb 						#echo >&2 "[$#] [$1] [$2] [$3]"
    308  1.54       apb 						/sbin/ifconfig $int "$@"
    309  1.54       apb 					)
    310  1.54       apb 					;;
    311  1.54       apb 				esac
    312  1.54       apb 			done
    313   1.1     lukem 			configured_interfaces="$configured_interfaces $int"
    314   1.1     lukem 		done
    315   1.1     lukem 		echo "."
    316   1.1     lukem 	fi
    317   1.1     lukem 
    318  1.48       cjs 	echo -n "Adding interface aliases:"
    319  1.48       cjs 
    320   1.1     lukem 	# Check if each configured interface xxN has an $ifaliases_xxN variable
    321   1.1     lukem 	# associated, then configure additional IP addresses for that interface.
    322   1.1     lukem 	# The variable contains a list of "address netmask" pairs, with
    323   1.1     lukem 	# "netmask" set to "-" if the interface default netmask is to be used.
    324   1.1     lukem 	#
    325  1.54       apb 	# Note that $ifaliases_xxN works only in certain cases and its
    326  1.54       apb 	# use is not recommended.  Use /etc/ifconfig.xxN or multiple
    327  1.54       apb 	# commands in $ifconfig_xxN instead.
    328   1.1     lukem 	#
    329  1.48       cjs 	for int in lo0 $configured_interfaces; do
    330  1.20  nisimura 		eval args=\$ifaliases_$int
    331   1.1     lukem 		if [ -n "$args" ]; then
    332   1.1     lukem 			set -- $args
    333   1.1     lukem 			while [ $# -ge 2 ]; do
    334   1.1     lukem 				addr=$1 ; net=$2 ; shift 2
    335   1.1     lukem 				if [ "$net" = "-" ]; then
    336  1.16  jdolecek 					# for compatibility only, obsolete
    337  1.53      reed 					/sbin/ifconfig $int inet alias $addr
    338   1.1     lukem 				else
    339  1.53      reed 					/sbin/ifconfig $int inet alias $addr \
    340   1.1     lukem 					    netmask $net
    341   1.1     lukem 				fi
    342  1.48       cjs 				echo -n " $int:$addr"
    343   1.1     lukem 			done
    344   1.1     lukem 		fi
    345   1.1     lukem 	done
    346   1.1     lukem 
    347   1.1     lukem 	# /etc/ifaliases, if it exists, contains the names of additional IP
    348   1.1     lukem 	# addresses for each interface. It is formatted as a series of lines
    349   1.1     lukem 	# that contain
    350   1.1     lukem 	#	address interface netmask
    351   1.1     lukem 	#
    352  1.54       apb 	# Note that /etc/ifaliases works only in certain cases and its
    353  1.54       apb 	# use is not recommended.  Use /etc/ifconfig.xxN or multiple
    354  1.54       apb 	# commands in $ifconfig_xxN instead.
    355   1.1     lukem 	#
    356   1.1     lukem 	if [ -f /etc/ifaliases ]; then
    357   1.1     lukem 		while read addr int net; do
    358   1.1     lukem 			if [ -z "$net" ]; then
    359  1.16  jdolecek 				# for compatibility only, obsolete
    360  1.53      reed 				/sbin/ifconfig $int inet alias $addr
    361   1.1     lukem 			else
    362  1.53      reed 				/sbin/ifconfig $int inet alias $addr netmask $net
    363   1.1     lukem 			fi
    364  1.20  nisimura 		done < /etc/ifaliases
    365   1.1     lukem 	fi
    366   1.1     lukem 
    367  1.56       apb 	echo "." # for "Adding interface aliases:"
    368  1.56       apb 
    369  1.56       apb 	# Check $defaultroute, then /etc/mygate, for the name or address
    370  1.56       apb 	# of my IPv4 gateway host. If using a name, that name must be in
    371  1.56       apb 	# /etc/hosts.
    372  1.56       apb 	#
    373  1.56       apb 	if [ -z "$defaultroute" ] && [ -f /etc/mygate ]; then
    374  1.56       apb 		defaultroute=$(cat /etc/mygate)
    375  1.56       apb 	fi
    376  1.56       apb 	if [ -n "$defaultroute" ]; then
    377  1.56       apb 		/sbin/route add default $defaultroute
    378  1.56       apb 	fi
    379  1.56       apb 
    380  1.56       apb 	# Check $defaultroute6, then /etc/mygate6, for the name or address
    381  1.56       apb 	# of my IPv6 gateway host. If using a name, that name must be in
    382  1.56       apb 	# /etc/hosts.  Note that the gateway host address must be a link-local
    383  1.56       apb 	# address if it is not using an stf* interface.
    384  1.56       apb 	#
    385  1.56       apb 	if [ -z "$defaultroute6" ] && [ -f /etc/mygate6 ]; then
    386  1.56       apb 		defaultroute6=$(cat /etc/mygate6)
    387  1.56       apb 	fi
    388  1.56       apb 	if [ -n "$defaultroute6" ]; then
    389  1.56       apb 		if [ "$ip6mode" = "autohost" ]; then
    390  1.56       apb 			echo
    391  1.56       apb 			warn \
    392  1.56       apb 	    "ip6mode is set to 'autohost' and a v6 default route is also set."
    393  1.56       apb 		fi
    394  1.56       apb 		/sbin/route add -inet6 default $defaultroute6
    395  1.56       apb 	fi
    396  1.48       cjs 
    397  1.30    itojun 	# IPv6 interface autoconfiguration.
    398   1.1     lukem 	#
    399  1.53      reed 	if /sbin/ifconfig lo0 inet6 >/dev/null 2>&1; then
    400  1.17    itojun 		# wait till DAD is completed. always invoke it in case
    401  1.17    itojun 		# if are configured manually by ifconfig
    402  1.17    itojun 		#
    403  1.53      reed 		dadcount=$(/sbin/sysctl -n net.inet6.ip6.dad_count 2>/dev/null)
    404  1.17    itojun 		sleep $dadcount
    405  1.17    itojun 		sleep 1
    406  1.17    itojun 
    407   1.1     lukem 		if checkyesno rtsol; then
    408   1.1     lukem 			if [ "$ip6mode" = "autohost" ]; then
    409   1.1     lukem 				echo 'Sending router solicitation...'
    410  1.53      reed 				/sbin/rtsol $rtsol_flags
    411   1.1     lukem 			else
    412   1.1     lukem 				echo
    413   1.1     lukem 				warn \
    414   1.1     lukem 			    "ip6mode must be set to 'autohost' to use rtsol."
    415   1.1     lukem 			fi
    416  1.17    itojun 
    417  1.18    itojun 			# wait till DAD is completed, for global addresses
    418  1.18    itojun 			# configured by router advert message.
    419  1.17    itojun 			#
    420  1.17    itojun 			sleep $dadcount
    421  1.17    itojun 			sleep 1
    422   1.1     lukem 		fi
    423  1.42  christos 	fi
    424  1.42  christos 
    425   1.1     lukem 	# XXX this must die
    426   1.1     lukem 	if [ -s /etc/netstart.local ]; then
    427   1.1     lukem 		sh /etc/netstart.local start
    428   1.1     lukem 	fi
    429   1.1     lukem }
    430   1.1     lukem 
    431   1.1     lukem network_stop()
    432   1.1     lukem {
    433   1.1     lukem 	echo "Stopping network."
    434   1.1     lukem 
    435   1.1     lukem 	# XXX this must die
    436   1.1     lukem 	if [ -s /etc/netstart.local ]; then
    437   1.1     lukem 		sh /etc/netstart.local stop
    438   1.1     lukem 	fi
    439   1.1     lukem 
    440   1.1     lukem 	echo "Deleting aliases."
    441   1.1     lukem 	if [ -f /etc/ifaliases ]; then
    442   1.1     lukem 		while read addr int net; do
    443  1.53      reed 			/sbin/ifconfig $int inet delete $addr
    444  1.20  nisimura 		done < /etc/ifaliases
    445   1.1     lukem 	fi
    446   1.1     lukem 
    447  1.53      reed 	for int in $(/sbin/ifconfig -lu); do
    448  1.20  nisimura 		eval args=\$ifaliases_$int
    449   1.1     lukem 		if [ -n "$args" ]; then
    450   1.1     lukem 			set -- $args
    451   1.1     lukem 			while [ $# -ge 2 ]; do
    452   1.1     lukem 				addr=$1 ; net=$2 ; shift 2
    453  1.53      reed 				/sbin/ifconfig $int inet delete $addr
    454   1.1     lukem 			done
    455   1.1     lukem 		fi
    456   1.1     lukem 	done
    457   1.1     lukem 
    458   1.1     lukem 	# down interfaces
    459   1.1     lukem 	#
    460   1.1     lukem 	echo -n 'Downing network interfaces:'
    461   1.1     lukem 	if [ "$net_interfaces" != NO ]; then
    462   1.1     lukem 		if checkyesno auto_ifconfig; then
    463  1.53      reed 			tmp=$(/sbin/ifconfig -l)
    464   1.1     lukem 		else
    465   1.1     lukem 			tmp="$net_interfaces"
    466   1.1     lukem 		fi
    467   1.1     lukem 		for int in $tmp; do
    468  1.20  nisimura 			eval args=\$ifconfig_$int
    469   1.2     veego 			if [ -n "$args" ] || [ -f /etc/ifconfig.$int ]; then
    470   1.1     lukem 				echo -n " $int"
    471  1.58       roy 				if [ -f /var/run/dhcpcd-$int.pid ]; then
    472  1.58       roy 					/sbin/dhcpcd -k $int 2> /dev/null
    473  1.58       roy 				fi
    474  1.53      reed 				/sbin/ifconfig $int down
    475  1.53      reed 				if /sbin/ifconfig $int destroy 2>/dev/null && \
    476  1.39      tron 				   checkyesno ipfilter; then
    477  1.39      tron 					# resync ipf(4)
    478  1.53      reed 					/sbin/ipf -y >/dev/null
    479  1.39      tron 				fi
    480   1.1     lukem 			fi
    481   1.1     lukem 		done
    482   1.1     lukem 		echo "."
    483   1.1     lukem 	fi
    484   1.1     lukem 
    485   1.1     lukem 	# flush routes
    486   1.1     lukem 	#
    487  1.53      reed 	/sbin/route -qn flush
    488  1.38      tron 
    489   1.1     lukem }
    490   1.1     lukem 
    491  1.47     lukem load_rc_config $name
    492  1.47     lukem load_rc_config_var dhclient dhclient
    493  1.58       roy load_rc_config_var dhcpcd dhcpcd
    494  1.47     lukem load_rc_config_var ipfilter ipfilter
    495   1.1     lukem run_rc_command "$1"
    496