xref: /freebsd/sbin/dhclient/dhclient-script (revision e2dc8d789f68a9a2267c7f1006aba36c7840b177)
147c08596SBrooks Davis#!/bin/sh
247c08596SBrooks Davis#
347c08596SBrooks Davis# $OpenBSD: dhclient-script,v 1.6 2004/05/06 18:22:41 claudio Exp $
48750adafSBrooks Davis# $FreeBSD$
547c08596SBrooks Davis#
647c08596SBrooks Davis# Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org>
747c08596SBrooks Davis#
847c08596SBrooks Davis# Permission to use, copy, modify, and distribute this software for any
947c08596SBrooks Davis# purpose with or without fee is hereby granted, provided that the above
1047c08596SBrooks Davis# copyright notice and this permission notice appear in all copies.
1147c08596SBrooks Davis#
1247c08596SBrooks Davis# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1347c08596SBrooks Davis# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1447c08596SBrooks Davis# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1547c08596SBrooks Davis# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1647c08596SBrooks Davis# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1747c08596SBrooks Davis# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1847c08596SBrooks Davis# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1947c08596SBrooks Davis#
2047c08596SBrooks Davis#
2147c08596SBrooks Davis
22b1f35e43SBrooks DavisARP=/usr/sbin/arp
238750adafSBrooks DavisHOSTNAME=/bin/hostname
2460932bc9SAndrew ThompsonIFCONFIG='/sbin/ifconfig -n'
258750adafSBrooks Davis
268750adafSBrooks DavisLOCALHOST=127.0.0.1
278750adafSBrooks Davis
288750adafSBrooks Davisif [ -x /usr/bin/logger ]; then
298750adafSBrooks Davis	LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
308750adafSBrooks Daviselse
318750adafSBrooks Davis	LOGGER=echo
328750adafSBrooks Davisfi
338750adafSBrooks Davis
3447c08596SBrooks Davis#
3547c08596SBrooks Davis# Helper functions that implement common actions.
3647c08596SBrooks Davis#
3747c08596SBrooks Davis
388750adafSBrooks Davischeck_hostname() {
398750adafSBrooks Davis	current_hostname=`$HOSTNAME`
408750adafSBrooks Davis	if [ -z "$current_hostname" ]; then
418750adafSBrooks Davis		$LOGGER "New Hostname ($interface): $new_host_name"
428750adafSBrooks Davis		$HOSTNAME $new_host_name
438750adafSBrooks Davis	elif [ "$current_hostname" = "$old_host_name" -a \
448750adafSBrooks Davis	       "$new_host_name" != "$old_host_name" ]; then
458750adafSBrooks Davis		$LOGGER "New Hostname ($interface): $new_host_name"
468750adafSBrooks Davis		$HOSTNAME $new_host_name
4747c08596SBrooks Davis	fi
4847c08596SBrooks Davis}
4947c08596SBrooks Davis
508750adafSBrooks Davisarp_flush() {
518750adafSBrooks Davis	arp -an -i $interface | \
528750adafSBrooks Davis		sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' | \
538750adafSBrooks Davis		sh >/dev/null 2>&1
548750adafSBrooks Davis}
558750adafSBrooks Davis
568750adafSBrooks Davisdelete_old_address() {
5760932bc9SAndrew Thompson	eval "$IFCONFIG $interface inet -alias $old_ip_address $medium"
588750adafSBrooks Davis}
598750adafSBrooks Davis
6047c08596SBrooks Davisadd_new_address() {
6160932bc9SAndrew Thompson	eval "$IFCONFIG $interface \
6247c08596SBrooks Davis		inet $new_ip_address \
6347c08596SBrooks Davis		netmask $new_subnet_mask \
6447c08596SBrooks Davis		broadcast $new_broadcast_address \
65001f040aSBrooks Davis		$medium"
6647c08596SBrooks Davis
678750adafSBrooks Davis	$LOGGER "New IP Address ($interface): $new_ip_address"
688750adafSBrooks Davis	$LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
698750adafSBrooks Davis	$LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
708750adafSBrooks Davis	$LOGGER "New Routers ($interface): $new_routers"
7147c08596SBrooks Davis}
7247c08596SBrooks Davis
7347c08596SBrooks Davisdelete_old_alias() {
7447c08596SBrooks Davis	if [ -n "$alias_ip_address" ]; then
7560932bc9SAndrew Thompson		$IFCONFIG $interface inet -alias $alias_ip_address > /dev/null 2>&1
767e82455eSBrooks Davis		#route delete $alias_ip_address $LOCALHOST > /dev/null 2>&1
7747c08596SBrooks Davis	fi
7847c08596SBrooks Davis}
7947c08596SBrooks Davis
8047c08596SBrooks Davisadd_new_alias() {
8147c08596SBrooks Davis	if [ -n "$alias_ip_address" ]; then
8260932bc9SAndrew Thompson		$IFCONFIG $interface inet alias $alias_ip_address netmask \
8347c08596SBrooks Davis		    $alias_subnet_mask
847e82455eSBrooks Davis		#route add $alias_ip_address $LOCALHOST
8547c08596SBrooks Davis	fi
8647c08596SBrooks Davis}
8747c08596SBrooks Davis
882fcc7370SEd Mastefill_classless_routes() {
892fcc7370SEd Maste	set $1
909f0d81baSEd Maste	while [ $# -ge 5 ]; do
912fcc7370SEd Maste		if [ $1 -eq 0 ]; then
922fcc7370SEd Maste			route="default"
932fcc7370SEd Maste		elif [ $1 -le 8 ]; then
942fcc7370SEd Maste			route="$2.0.0.0/$1"
952fcc7370SEd Maste			shift
962fcc7370SEd Maste		elif [ $1 -le 16 ]; then
972fcc7370SEd Maste			route="$2.$3.0.0/$1"
982fcc7370SEd Maste			shift; shift
992fcc7370SEd Maste		elif [ $1 -le 24 ]; then
1002fcc7370SEd Maste			route="$2.$3.$4.0/$1"
1012fcc7370SEd Maste			shift; shift; shift
1022fcc7370SEd Maste		else
1032fcc7370SEd Maste			route="$2.$3.$4.$5/$1"
1042fcc7370SEd Maste			shift; shift; shift; shift
1052fcc7370SEd Maste		fi
1062fcc7370SEd Maste		shift
1072fcc7370SEd Maste		router="$1.$2.$3.$4"
1082fcc7370SEd Maste		classless_routes="$classless_routes $route $router"
1092fcc7370SEd Maste		shift; shift; shift; shift
1102fcc7370SEd Maste	done
1112fcc7370SEd Maste}
1122fcc7370SEd Maste
11347c08596SBrooks Davisdelete_old_routes() {
1147e82455eSBrooks Davis	#route delete "$old_ip_address" $LOCALHOST >/dev/null 2>&1
1152fcc7370SEd Maste	if [ -n "$old_classless_routes" ]; then
1162fcc7370SEd Maste		fill_classless_routes "$old_classless_routes"
1172fcc7370SEd Maste		set $classless_routes
1182fcc7370SEd Maste		while [ $# -gt 1 ]; do
1192fcc7370SEd Maste			route delete "$1" "$2"
1202fcc7370SEd Maste			shift; shift
1212fcc7370SEd Maste		done
1222fcc7370SEd Maste		return 0;
1232fcc7370SEd Maste	fi
1242fcc7370SEd Maste
125d5354256SBrooks Davis	# If we supported multiple default routes, we'd be removing each
126d5354256SBrooks Davis	# one here.  We don't so just delete the default route if it's
127d5354256SBrooks Davis	# through our interface.
128d5354256SBrooks Davis	if is_default_interface; then
129d5354256SBrooks Davis		route delete default >/dev/null 2>&1
1308750adafSBrooks Davis	fi
13147c08596SBrooks Davis
13247c08596SBrooks Davis	if [ -n "$old_static_routes" ]; then
13347c08596SBrooks Davis		set $old_static_routes
13447c08596SBrooks Davis		while [ $# -gt 1 ]; do
13547c08596SBrooks Davis			route delete "$1" "$2"
13647c08596SBrooks Davis			shift; shift
13747c08596SBrooks Davis		done
13847c08596SBrooks Davis	fi
13947c08596SBrooks Davis
1408750adafSBrooks Davis	arp_flush
14147c08596SBrooks Davis}
14247c08596SBrooks Davis
14347c08596SBrooks Davisadd_new_routes() {
1447e82455eSBrooks Davis	#route add $new_ip_address $LOCALHOST >/dev/null 2>&1
1452fcc7370SEd Maste
1462fcc7370SEd Maste	# RFC 3442: If the DHCP server returns both a Classless Static
1472fcc7370SEd Maste	# Routes option and a Router option, the DHCP client MUST ignore
1482fcc7370SEd Maste	# the Router option.
1492fcc7370SEd Maste	#
1502fcc7370SEd Maste	# DHCP clients that support this option (Classless Static Routes)
1512fcc7370SEd Maste	# MUST NOT install the routes specified in the Static Routes
1522fcc7370SEd Maste	# option (option code 33) if both a Static Routes option and the
1532fcc7370SEd Maste	# Classless Static Routes option are provided.
1542fcc7370SEd Maste
1552fcc7370SEd Maste	if [ -n "$new_classless_routes" ]; then
1562fcc7370SEd Maste		fill_classless_routes "$new_classless_routes"
1572fcc7370SEd Maste		$LOGGER "New Classless Static Routes ($interface): $classless_routes"
1582fcc7370SEd Maste		set $classless_routes
1592fcc7370SEd Maste		while [ $# -gt 1 ]; do
1602fcc7370SEd Maste			if [ "0.0.0.0" = "$2" ]; then
1612fcc7370SEd Maste				route add "$1" -iface "$interface"
1622fcc7370SEd Maste			else
1632fcc7370SEd Maste				route add "$1" "$2"
1642fcc7370SEd Maste			fi
1652fcc7370SEd Maste			shift; shift
1662fcc7370SEd Maste		done
1672fcc7370SEd Maste		return
1682fcc7370SEd Maste	fi
1692fcc7370SEd Maste
17047c08596SBrooks Davis	for router in $new_routers; do
171d5354256SBrooks Davis		if is_default_interface; then
172d5354256SBrooks Davis
17347c08596SBrooks Davis			if [ "$new_ip_address" = "$router" ]; then
17447c08596SBrooks Davis				route add default -iface $router >/dev/null 2>&1
17547c08596SBrooks Davis			else
176fd6ecc18SKristof Provost				if [ "$new_subnet_mask" = "255.255.255.255" ]; then
177fd6ecc18SKristof Provost					route add "$router" -iface "$interface" >/dev/null 2>&1
178fd6ecc18SKristof Provost				fi
179fd6ecc18SKristof Provost
18047c08596SBrooks Davis				route add default $router >/dev/null 2>&1
18147c08596SBrooks Davis			fi
182d5354256SBrooks Davis		fi
18347c08596SBrooks Davis		# 2nd and subsequent default routers error out, so explicitly
18447c08596SBrooks Davis		# stop processing the list after the first one.
18547c08596SBrooks Davis		break
18647c08596SBrooks Davis	done
18747c08596SBrooks Davis
18847c08596SBrooks Davis	if [ -n "$new_static_routes" ]; then
1898750adafSBrooks Davis		$LOGGER "New Static Routes ($interface): $new_static_routes"
19047c08596SBrooks Davis		set $new_static_routes
19147c08596SBrooks Davis		while [ $# -gt 1 ]; do
19247c08596SBrooks Davis			route add $1 $2
19347c08596SBrooks Davis			shift; shift
19447c08596SBrooks Davis		done
19547c08596SBrooks Davis	fi
19647c08596SBrooks Davis}
19747c08596SBrooks Davis
19847c08596SBrooks Davisadd_new_resolv_conf() {
19947c08596SBrooks Davis	# XXX Old code did not create/update resolv.conf unless both
20047c08596SBrooks Davis	# $new_domain_name and $new_domain_name_servers were provided.  PR
20147c08596SBrooks Davis	# #3135 reported some ISP's only provide $new_domain_name_servers and
20247c08596SBrooks Davis	# thus broke the script. This code creates the resolv.conf if either
20347c08596SBrooks Davis	# are provided.
20447c08596SBrooks Davis
205f1bacaa5SBrooks Davis	local tmpres=/var/run/resolv.conf.${interface}
20690158aeeSWes Peters	rm -f $tmpres
20747c08596SBrooks Davis
208409139f0SJean-Sébastien Pédron	if [ -n "$new_domain_search" ]; then
209409139f0SJean-Sébastien Pédron		echo "search $new_domain_search" >>$tmpres
210409139f0SJean-Sébastien Pédron	elif [ -n "$new_domain_name" ]; then
21190158aeeSWes Peters		echo "search $new_domain_name" >>$tmpres
21247c08596SBrooks Davis	fi
21347c08596SBrooks Davis
21447c08596SBrooks Davis	if [ -n "$new_domain_name_servers" ]; then
21547c08596SBrooks Davis		for nameserver in $new_domain_name_servers; do
21690158aeeSWes Peters			echo "nameserver $nameserver" >>$tmpres
21747c08596SBrooks Davis		done
21847c08596SBrooks Davis	fi
21947c08596SBrooks Davis
22090158aeeSWes Peters	if [ -f $tmpres ]; then
22147c08596SBrooks Davis		if [ -f /etc/resolv.conf.tail ]; then
22290158aeeSWes Peters			cat /etc/resolv.conf.tail >>$tmpres
22347c08596SBrooks Davis		fi
22447c08596SBrooks Davis
2259201145dSHajimu UMEMOTO		case $resolvconf_enable in
2269201145dSHajimu UMEMOTO		# "no", "false", "off", or "0"
2279201145dSHajimu UMEMOTO		[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
228dd415a50SBrooks Davis			# When resolv.conf is not changed actually, we don't
229dd415a50SBrooks Davis			# need to update it.
230dd415a50SBrooks Davis			# If /usr is not mounted yet, we cannot use cmp, then
231dd415a50SBrooks Davis			# the following test fails.  In such case, we simply
232dd415a50SBrooks Davis			# ignore an error and do update resolv.conf.
23390158aeeSWes Peters			if cmp -s $tmpres /etc/resolv.conf; then
23490158aeeSWes Peters				rm -f $tmpres
235dd415a50SBrooks Davis				return 0
236dd415a50SBrooks Davis			fi 2>/dev/null
237dd415a50SBrooks Davis
2389201145dSHajimu UMEMOTO			# In case (e.g. during OpenBSD installs)
2399201145dSHajimu UMEMOTO			# /etc/resolv.conf is a symbolic link, take
2409201145dSHajimu UMEMOTO			# care to preserve the link and write the new
2419201145dSHajimu UMEMOTO			# data in the correct location.
24247c08596SBrooks Davis
24347c08596SBrooks Davis			if [ -f /etc/resolv.conf ]; then
24447c08596SBrooks Davis				cat /etc/resolv.conf > /etc/resolv.conf.save
24547c08596SBrooks Davis			fi
24690158aeeSWes Peters			cat $tmpres > /etc/resolv.conf
24747c08596SBrooks Davis
24847c08596SBrooks Davis			# Try to ensure correct ownership and permissions.
24947c08596SBrooks Davis			chown -RL root:wheel /etc/resolv.conf
25047c08596SBrooks Davis			chmod -RL 644 /etc/resolv.conf
2519201145dSHajimu UMEMOTO			;;
2529201145dSHajimu UMEMOTO
2539201145dSHajimu UMEMOTO		*)
2549201145dSHajimu UMEMOTO			/sbin/resolvconf -a ${interface} < $tmpres
2559201145dSHajimu UMEMOTO			;;
2569201145dSHajimu UMEMOTO		esac
2579201145dSHajimu UMEMOTO
2589201145dSHajimu UMEMOTO		rm -f $tmpres
25947c08596SBrooks Davis
26047c08596SBrooks Davis		return 0
26147c08596SBrooks Davis	fi
26247c08596SBrooks Davis
26347c08596SBrooks Davis	return 1
26447c08596SBrooks Davis}
26547c08596SBrooks Davis
266d6790d5aSBrooks Davis# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
267d6790d5aSBrooks Davisexit_with_hooks() {
268d6790d5aSBrooks Davis	exit_status=$1
269d6790d5aSBrooks Davis	if [ -f /etc/dhclient-exit-hooks ]; then
270d6790d5aSBrooks Davis		. /etc/dhclient-exit-hooks
271d6790d5aSBrooks Davis	fi
272d6790d5aSBrooks Davis	# probably should do something with exit status of the local script
273d6790d5aSBrooks Davis	exit $exit_status
274d6790d5aSBrooks Davis}
275d6790d5aSBrooks Davis
276d5354256SBrooks Davis# Get the interface with the current ipv4 default route on it using only
277d5354256SBrooks Davis# commands that are available prior to /usr being mounted.
278d5354256SBrooks Davisis_default_interface()
279d5354256SBrooks Davis{
2809761cdd8SBrooks Davis	routeget="`route -n get -inet default`"
281d5354256SBrooks Davis	oldifs="$IFS"
282d5354256SBrooks Davis	IFS="
283d5354256SBrooks Davis"
284d5354256SBrooks Davis	defif=
285d5354256SBrooks Davis	for line in $routeget ; do
286d5354256SBrooks Davis		case $line in
287d5354256SBrooks Davis		*interface:*)
288d5354256SBrooks Davis			defif=${line##*: }
289d5354256SBrooks Davis			;;
290d5354256SBrooks Davis		esac
291d5354256SBrooks Davis	done
292d5354256SBrooks Davis	IFS=${oldifs}
293d5354256SBrooks Davis
294d5354256SBrooks Davis	if [ -z "$defif" -o "$defif" = "$interface" ]; then
295d5354256SBrooks Davis		return 0
296d5354256SBrooks Davis	else
297d5354256SBrooks Davis		return 1
298d5354256SBrooks Davis	fi
299d5354256SBrooks Davis}
300d5354256SBrooks Davis
30147c08596SBrooks Davis#
30247c08596SBrooks Davis# Start of active code.
30347c08596SBrooks Davis#
30447c08596SBrooks Davis
305d5fedb6eSBrooks Davis# Invoke the local dhcp client enter hooks, if they exist.
306d5fedb6eSBrooks Davisif [ -f /etc/dhclient-enter-hooks ]; then
307d5fedb6eSBrooks Davis	exit_status=0
308d5fedb6eSBrooks Davis	. /etc/dhclient-enter-hooks
309d5fedb6eSBrooks Davis	# allow the local script to abort processing of this state
310d5fedb6eSBrooks Davis	# local script must set exit_status variable to nonzero.
311d5fedb6eSBrooks Davis	if [ $exit_status -ne 0 ]; then
312d5fedb6eSBrooks Davis		exit $exit_status
313d5fedb6eSBrooks Davis	fi
314d5fedb6eSBrooks Davisfi
315d5fedb6eSBrooks Davis
3169201145dSHajimu UMEMOTO: ${resolvconf_enable="YES"}
3179201145dSHajimu UMEMOTO
31847c08596SBrooks Daviscase $reason in
31947c08596SBrooks DavisMEDIUM)
32060932bc9SAndrew Thompson	eval "$IFCONFIG $interface $medium"
32147c08596SBrooks Davis	sleep 1
32247c08596SBrooks Davis	;;
32347c08596SBrooks Davis
32447c08596SBrooks DavisPREINIT)
32547c08596SBrooks Davis	delete_old_alias
326*e2dc8d78SAlexander V. Chernikov	eval "$IFCONFIG $interface up"
32747c08596SBrooks Davis	;;
32847c08596SBrooks Davis
32947c08596SBrooks DavisARPCHECK|ARPSEND)
33047c08596SBrooks Davis	;;
33147c08596SBrooks Davis
33247c08596SBrooks DavisBOUND|RENEW|REBIND|REBOOT)
3338750adafSBrooks Davis	check_hostname
33447c08596SBrooks Davis	if [ -n "$old_ip_address" ]; then
33547c08596SBrooks Davis		if [ "$old_ip_address" != "$alias_ip_address" ]; then
33647c08596SBrooks Davis			delete_old_alias
33747c08596SBrooks Davis		fi
33847c08596SBrooks Davis		if [ "$old_ip_address" != "$new_ip_address" ]; then
33947c08596SBrooks Davis			delete_old_address
34047c08596SBrooks Davis			delete_old_routes
34147c08596SBrooks Davis		fi
34247c08596SBrooks Davis	fi
34347c08596SBrooks Davis	if [ "$reason" = BOUND ] || \
34447c08596SBrooks Davis	   [ "$reason" = REBOOT ] || \
34547c08596SBrooks Davis	   [ -z "$old_ip_address" ] || \
34647c08596SBrooks Davis	   [ "$old_ip_address" != "$new_ip_address" ]; then
34747c08596SBrooks Davis		add_new_address
34847c08596SBrooks Davis		add_new_routes
34947c08596SBrooks Davis	fi
35047c08596SBrooks Davis	if [ "$new_ip_address" != "$alias_ip_address" ]; then
35147c08596SBrooks Davis		add_new_alias
35247c08596SBrooks Davis	fi
353d5354256SBrooks Davis	if is_default_interface; then
35447c08596SBrooks Davis		add_new_resolv_conf
355d5354256SBrooks Davis	fi
35647c08596SBrooks Davis	;;
35747c08596SBrooks Davis
35847c08596SBrooks DavisEXPIRE|FAIL)
35947c08596SBrooks Davis	delete_old_alias
36047c08596SBrooks Davis	if [ -n "$old_ip_address" ]; then
36147c08596SBrooks Davis		delete_old_address
36247c08596SBrooks Davis		delete_old_routes
36347c08596SBrooks Davis	fi
364b1f35e43SBrooks Davis	if [ -x $ARP ]; then
365b1f35e43SBrooks Davis		$ARP -d -a -i $interface
366b1f35e43SBrooks Davis	fi
36747c08596SBrooks Davis	# XXX Why add alias we just deleted above?
36847c08596SBrooks Davis	add_new_alias
369d5354256SBrooks Davis	if is_default_interface; then
3709201145dSHajimu UMEMOTO		case $resolvconf_enable in
3719201145dSHajimu UMEMOTO		# "no", "false", "off", or "0"
3729201145dSHajimu UMEMOTO		[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
37347c08596SBrooks Davis			if [ -f /etc/resolv.conf.save ]; then
37447c08596SBrooks Davis				cat /etc/resolv.conf.save > /etc/resolv.conf
37547c08596SBrooks Davis			fi
3769201145dSHajimu UMEMOTO			;;
3779201145dSHajimu UMEMOTO		*)
3789201145dSHajimu UMEMOTO			/sbin/resolvconf -d ${interface}
3799201145dSHajimu UMEMOTO			;;
3809201145dSHajimu UMEMOTO		esac
381d5354256SBrooks Davis	fi
38247c08596SBrooks Davis	;;
38347c08596SBrooks Davis
38447c08596SBrooks DavisTIMEOUT)
38547c08596SBrooks Davis	delete_old_alias
38647c08596SBrooks Davis	add_new_address
38747c08596SBrooks Davis	sleep 1
38847c08596SBrooks Davis	if [ -n "$new_routers" ]; then
3898750adafSBrooks Davis		$LOGGER "New Routers ($interface): $new_routers"
39047c08596SBrooks Davis		set "$new_routers"
391b0864f3aSBrooks Davis		if ping -q -c 1 -t 1 "$1"; then
39247c08596SBrooks Davis			if [ "$new_ip_address" != "$alias_ip_address" ]; then
39347c08596SBrooks Davis				add_new_alias
39447c08596SBrooks Davis			fi
39547c08596SBrooks Davis			add_new_routes
396d5354256SBrooks Davis			if ! is_default_interface; then
397d5354256SBrooks Davis				exit_with_hooks 0
398d5354256SBrooks Davis			fi
39947c08596SBrooks Davis			if add_new_resolv_conf; then
400d6790d5aSBrooks Davis				exit_with_hooks 0
40147c08596SBrooks Davis			fi
40247c08596SBrooks Davis		fi
40347c08596SBrooks Davis	fi
40460932bc9SAndrew Thompson	eval "$IFCONFIG $interface inet -alias $new_ip_address $medium"
40547c08596SBrooks Davis	delete_old_routes
406d6790d5aSBrooks Davis	exit_with_hooks 1
40747c08596SBrooks Davis	;;
40847c08596SBrooks Davisesac
40947c08596SBrooks Davis
410d6790d5aSBrooks Davisexit_with_hooks 0
411