3 # $Id: freebsd,v 1.1.1.1 2005/12/07 10:50:31 sonic_amiga Exp $
7 if [ -x /usr
/bin
/logger
]; then
8 LOGGER
="/usr/bin/logger -s -p user.notice -t dhclient"
14 if [ x
"$new_domain_name_servers" != x
]; then
15 if [ "x$new_domain_name" != x
]; then
16 ( echo search
$new_domain_name >/etc
/resolv.conf
)
19 if [ -e /etc
/resolv.conf
] ; then
20 ( rm /etc
/resolv.conf
)
23 ( touch /etc
/resolv.conf
)
27 if [ $exit_status -ne 0 ]; then
28 $LOGGER "WARNING: Unable to update resolv.conf: Error $exit_status"
30 for nameserver
in $new_domain_name_servers; do
31 ( echo nameserver
$nameserver >>/etc
/resolv.conf
)
37 # Must be used on exit. Invokes the local dhcp client exit hooks, if any.
40 if [ -f /etc
/dhclient-exit-hooks
]; then
41 .
/etc
/dhclient-exit-hooks
43 # probably should do something with exit status of the local script
47 # Invoke the local dhcp client enter hooks, if they exist.
48 if [ -f /etc
/dhclient-enter-hooks
]; then
50 .
/etc
/dhclient-enter-hooks
51 # allow the local script to abort processing of this state
52 # local script must set exit_status variable to nonzero.
53 if [ $exit_status -ne 0 ]; then
58 if [ x
$new_network_number != x
]; then
59 $LOGGER New Network Number
: $new_network_number
62 if [ x
$new_broadcast_address != x
]; then
63 $LOGGER New Broadcast Address
: $new_broadcast_address
64 new_broadcast_arg
="broadcast $new_broadcast_address"
66 if [ x
$old_broadcast_address != x
]; then
67 old_broadcast_arg
="broadcast $old_broadcast_address"
69 if [ x
$new_subnet_mask != x
]; then
70 new_netmask_arg
="netmask $new_subnet_mask"
72 if [ x
$old_subnet_mask != x
]; then
73 old_netmask_arg
="netmask $old_subnet_mask"
75 if [ x
$alias_subnet_mask != x
]; then
76 alias_subnet_arg
="netmask $alias_subnet_mask"
79 if [ x
$reason = xMEDIUM
]; then
80 eval "ifconfig $interface $medium"
81 eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev
/null
2>&1
86 if [ x
$reason = xPREINIT
]; then
87 if [ x
$alias_ip_address != x
]; then
88 ifconfig
$interface inet
-alias $alias_ip_address > /dev
/null
2>&1
89 route delete
$alias_ip_address 127.0.0.1 > /dev
/null
2>&1
91 ifconfig
$interface inet
0.0.0.0 netmask
0.0.0.0 \
92 broadcast
255.255.255.255 up
96 if [ x
$reason = xARPCHECK
] ||
[ x
$reason = xARPSEND
]; then
100 if [ x
$reason = xBOUND
] ||
[ x
$reason = xRENEW
] || \
101 [ x
$reason = xREBIND
] ||
[ x
$reason = xREBOOT
]; then
102 current_hostname
=`/bin/hostname`
103 if [ x
$current_hostname = x
] || \
104 [ x
$current_hostname = x
$old_host_name ]; then
105 if [ x
$current_hostname = x
] || \
106 [ x
$new_host_name != x
$old_host_name ]; then
107 $LOGGER "New Hostname: $new_host_name"
108 hostname
$new_host_name
111 if [ x
$old_ip_address != x
] && [ x
$alias_ip_address != x
] && \
112 [ x
$alias_ip_address != x
$old_ip_address ]; then
113 ifconfig
$interface inet
-alias $alias_ip_address > /dev
/null
2>&1
114 route delete
$alias_ip_address 127.0.0.1 > /dev
/null
2>&1
116 if [ x
$old_ip_address != x
] && [ x
$old_ip_address != x
$new_ip_address ]
118 eval "ifconfig $interface inet -alias $old_ip_address $medium"
119 route delete
$old_ip_address 127.1 >/dev
/null
2>&1
120 for router
in $old_routers; do
121 route delete default
$router >/dev
/null
2>&1
123 if [ -n "$old_static_routes" ]; then
124 set -- $old_static_routes
125 while [ $# -gt 1 ]; do
130 arp
-n -a |
sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' |sh
132 if [ x
$old_ip_address = x
] ||
[ x
$old_ip_address != x
$new_ip_address ] || \
133 [ x
$reason = xBOUND
] ||
[ x
$reason = xREBOOT
]; then
134 eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
135 $new_broadcast_arg $medium"
136 $LOGGER "New IP Address ($interface): $new_ip_address"
137 $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
138 $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
139 if [ -n "$new_routers" ]; then
140 $LOGGER "New Routers: $new_routers"
142 route add
$new_ip_address 127.1 >/dev
/null
2>&1
143 for router
in $new_routers; do
144 route add default
$router >/dev
/null
2>&1
146 if [ -n "$new_static_routes" ]; then
147 $LOGGER "New Static Routes: $new_static_routes"
148 set -- $new_static_routes
149 while [ $# -gt 1 ]; do
155 if [ x
$new_ip_address != x
$alias_ip_address ] && [ x
$alias_ip_address != x
];
157 ifconfig
$interface inet
alias $alias_ip_address $alias_subnet_arg
158 route add
$alias_ip_address 127.0.0.1
164 if [ x
$reason = xEXPIRE
] ||
[ x
$reason = xFAIL
] ||
[ x
$reason = xRELEASE
] \
165 ||
[ x
$reason = xSTOP
]; then
166 if [ x
$alias_ip_address != x
]; then
167 ifconfig
$interface inet
-alias $alias_ip_address > /dev
/null
2>&1
168 route delete
$alias_ip_address 127.0.0.1 > /dev
/null
2>&1
170 if [ x
$old_ip_address != x
]; then
171 eval "ifconfig $interface inet -alias $old_ip_address $medium"
172 route delete
$old_ip_address 127.1 >/dev
/null
2>&1
173 for router
in $old_routers; do
174 route delete default
$router >/dev
/null
2>&1
176 if [ -n "$old_static_routes" ]; then
177 set -- $old_static_routes
178 while [ $# -gt 1 ]; do
183 arp
-n -a |
sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
186 if [ x
$alias_ip_address != x
]; then
187 ifconfig
$interface inet
alias $alias_ip_address $alias_subnet_arg
188 route add
$alias_ip_address 127.0.0.1
193 if [ x
$reason = xTIMEOUT
]; then
194 if [ x
$alias_ip_address != x
]; then
195 ifconfig
$interface inet
-alias $alias_ip_address > /dev
/null
2>&1
196 route delete
$alias_ip_address 127.0.0.1 > /dev
/null
2>&1
198 eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
199 $new_broadcast_arg $medium"
200 $LOGGER "New IP Address ($interface): $new_ip_address"
201 $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
202 $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
204 if [ -n "$new_routers" ]; then
205 $LOGGER "New Routers: $new_routers"
207 if ping -q -c 1 $1; then
208 if [ x
$new_ip_address != x
$alias_ip_address ] && \
209 [ x
$alias_ip_address != x
]; then
210 ifconfig
$interface inet
alias $alias_ip_address $alias_subnet_arg
211 route add
$alias_ip_address 127.0.0.1
213 route add
$new_ip_address 127.1 >/dev
/null
2>&1
214 for router
in $new_routers; do
215 route add default
$router >/dev
/null
2>&1
217 set -- $new_static_routes
218 while [ $# -gt 1 ]; do
226 eval "ifconfig $interface inet -alias $new_ip_address $medium"
227 for router
in $old_routers; do
228 route delete default
$router >/dev
/null
2>&1
230 if [ -n "$old_static_routes" ]; then
231 set -- $old_static_routes
232 while [ $# -gt 1 ]; do
237 arp
-n -a |
sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \