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