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