3 # $Id: freebsd,v 1.13.2.4 2002/06/09 22:37:55 murray Exp $
5 # $FreeBSD: src/contrib/isc-dhcp/client/scripts/freebsd,v 1.9.2.6 2003/03/02 16:42:38 murray Exp $
6 # $DragonFly: src/contrib/isc-dhcp/client/scripts/Attic/freebsd,v 1.2 2003/06/17 04:24:02 dillon Exp $
8 if [ -x /usr/bin/logger ]; then
9 LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
15 if [ x"$new_domain_name_servers" != x ]; then
16 if [ "x$new_domain_name" != x ]; then
17 echo search $new_domain_name >/etc/resolv.conf
21 for nameserver in $new_domain_name_servers; do
22 echo nameserver $nameserver >>/etc/resolv.conf
27 # Must be used on exit. Invokes the local dhcp client exit hooks, if any.
30 if [ -f /etc/dhclient-exit-hooks ]; then
31 . /etc/dhclient-exit-hooks
33 # probably should do something with exit status of the local script
37 # Invoke the local dhcp client enter hooks, if they exist.
38 if [ -f /etc/dhclient-enter-hooks ]; then
40 . /etc/dhclient-enter-hooks
41 # allow the local script to abort processing of this state
42 # local script must set exit_status variable to nonzero.
43 if [ $exit_status -ne 0 ]; then
48 if [ x$new_network_number != x ]; then
49 $LOGGER New Network Number: $new_network_number
52 if [ x$new_broadcast_address != x ]; then
53 $LOGGER New Broadcast Address: $new_broadcast_address
54 new_broadcast_arg="broadcast $new_broadcast_address"
56 if [ x$old_broadcast_address != x ]; then
57 old_broadcast_arg="broadcast $old_broadcast_address"
59 if [ x$new_subnet_mask != x ]; then
60 new_netmask_arg="netmask $new_subnet_mask"
62 if [ x$old_subnet_mask != x ]; then
63 old_netmask_arg="netmask $old_subnet_mask"
65 if [ x$alias_subnet_mask != x ]; then
66 alias_subnet_arg="netmask $alias_subnet_mask"
69 if [ x$reason = xMEDIUM ]; then
70 eval "ifconfig $interface $medium"
71 eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
76 if [ x$reason = xPREINIT ]; then
77 if [ x$alias_ip_address != x ]; then
78 ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
79 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
81 ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
82 broadcast 255.255.255.255 up
86 if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
90 if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
91 [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
92 current_hostname=`/bin/hostname`
93 if [ x$current_hostname = x ] || \
94 [ x$current_hostname = x$old_host_name ]; then
95 if [ x$current_hostname = x ] || \
96 [ x$new_host_name != x$old_host_name ]; then
97 $LOGGER "New Hostname: $new_host_name"
98 hostname $new_host_name
101 if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
102 [ x$alias_ip_address != x$old_ip_address ]; then
103 ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
104 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
106 if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
108 eval "ifconfig $interface inet -alias $old_ip_address $medium"
109 route delete $old_ip_address 127.1 >/dev/null 2>&1
110 for router in $old_routers; do
111 route delete default $router >/dev/null 2>&1
113 if [ -n "$old_static_routes" ]; then
114 set -- $old_static_routes
115 while [ $# -gt 1 ]; do
120 arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' |sh
122 if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
123 [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
124 eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
125 $new_broadcast_arg $medium"
126 $LOGGER "New IP Address ($interface): $new_ip_address"
127 $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
128 $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
129 if [ -n "$new_routers" ]; then
130 $LOGGER "New Routers: $new_routers"
132 route add $new_ip_address 127.1 >/dev/null 2>&1
133 for router in $new_routers; do
134 route add default $router >/dev/null 2>&1
136 if [ -n "$new_static_routes" ]; then
137 $LOGGER "New Static Routes: $new_static_routes"
138 set -- $new_static_routes
139 while [ $# -gt 1 ]; do
145 if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
147 ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
148 route add $alias_ip_address 127.0.0.1
154 if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
155 || [ x$reason = xSTOP ]; then
156 if [ x$alias_ip_address != x ]; then
157 ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
158 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
160 if [ x$old_ip_address != x ]; then
161 eval "ifconfig $interface inet -alias $old_ip_address $medium"
162 route delete $old_ip_address 127.1 >/dev/null 2>&1
163 for router in $old_routers; do
164 route delete default $router >/dev/null 2>&1
166 if [ -n "$old_static_routes" ]; then
167 set -- $old_static_routes
168 while [ $# -gt 1 ]; do
173 arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
176 if [ x$alias_ip_address != x ]; then
177 ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
178 route add $alias_ip_address 127.0.0.1
183 if [ x$reason = xTIMEOUT ]; then
184 if [ x$alias_ip_address != x ]; then
185 ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
186 route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
188 eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
189 $new_broadcast_arg $medium"
190 $LOGGER "New IP Address ($interface): $new_ip_address"
191 $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
192 $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
194 if [ -n "$new_routers" ]; then
195 $LOGGER "New Routers: $new_routers"
197 if ping -q -c 1 $1; then
198 if [ x$new_ip_address != x$alias_ip_address ] && \
199 [ x$alias_ip_address != x ]; then
200 ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
201 route add $alias_ip_address 127.0.0.1
203 route add $new_ip_address 127.1 >/dev/null 2>&1
204 for router in $new_routers; do
205 route add default $router >/dev/null 2>&1
207 set -- $new_static_routes
208 while [ $# -gt 1 ]; do
216 eval "ifconfig $interface inet -alias $new_ip_address $medium"
217 for router in $old_routers; do
218 route delete default $router >/dev/null 2>&1
220 if [ -n "$old_static_routes" ]; then
221 set -- $old_static_routes
222 while [ $# -gt 1 ]; do
227 arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \