]>
Commit | Line | Data |
---|---|---|
f1ddf01f AM |
1 | diff -urN dhcp-4.1.0a1.org/client/scripts/linux dhcp-4.1.0a1/client/scripts/linux |
2 | --- dhcp-4.1.0a1.org/client/scripts/linux 2008-01-17 00:02:10.000000000 +0100 | |
3 | +++ dhcp-4.1.0a1/client/scripts/linux 2008-03-12 22:39:33.024221732 +0100 | |
4 | @@ -1,296 +1,308 @@ | |
893aa178 JR |
5 | -#!/bin/bash |
6 | +#!/bin/sh | |
7 | # dhclient-script for Linux. Dan Halbert, March, 1997. | |
8 | # Updated for Linux 2.[12] by Brian J. Murrell, January 1999. | |
9 | -# No guarantees about this. I'm a novice at the details of Linux | |
10 | -# networking. | |
11 | ||
12 | # Notes: | |
13 | ||
14 | # 0. This script is based on the netbsd script supplied with dhcp-970306. | |
15 | ||
16 | -# 1. ifconfig down apparently deletes all relevant routes and flushes | |
17 | -# the arp cache, so this doesn't need to be done explicitly. | |
18 | +# 1. This script was modified to work with iproute2 | |
19 | ||
20 | -# 2. The alias address handling here has not been tested AT ALL. | |
21 | -# I'm just going by the doc of modern Linux ip aliasing, which uses | |
22 | -# notations like eth0:0, eth0:1, for each alias. | |
23 | - | |
24 | -# 3. I have to calculate the network address, and calculate the broadcast | |
25 | -# address if it is not supplied. This might be much more easily done | |
26 | -# by the dhclient C code, and passed on. | |
27 | - | |
28 | -# 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious | |
29 | -# of the $1 in its args. | |
7cecd907 AM |
30 | - |
31 | -# 'ip' just looks too weird. /sbin/ip looks less weird. | |
32 | -ip=/sbin/ip | |
893aa178 JR |
33 | +calc_prefix() |
34 | +{ | |
35 | + local old_IFS=$IFS | |
36 | + IFS='.' | |
37 | + local netmask=$(echo $1) | |
38 | + IFS=$old_IFS | |
39 | + | |
40 | + local ret=0 | |
41 | + local endp=0 | |
893aa178 JR |
42 | + for n in $netmask ; do |
43 | + for i in 128 64 32 16 8 4 2 1 ; do | |
44 | + if [ $(($n & $i)) -ne 0 ]; then | |
45 | + if [ $endp -eq 0 ]; then | |
46 | + ret=$(($ret + 1)) | |
47 | + else | |
48 | + echo "32" | |
49 | + return | |
50 | + fi | |
51 | + else | |
52 | + endp=1 | |
53 | + fi | |
54 | + done | |
55 | + done | |
56 | + echo $ret | |
57 | +} | |
58 | ||
59 | make_resolv_conf() { | |
60 | - if [ x"$new_domain_name_servers" != x ]; then | |
61 | - cat /dev/null > /etc/resolv.conf.dhclient | |
62 | - chmod 644 /etc/resolv.conf.dhclient | |
63 | - if [ x"$new_domain_search" != x ]; then | |
64 | - echo search $new_domain_search >> /etc/resolv.conf.dhclient | |
65 | - elif [ x"$new_domain_name" != x ]; then | |
66 | - # Note that the DHCP 'Domain Name Option' is really just a domain | |
67 | - # name, and that this practice of using the domain name option as | |
68 | - # a search path is both nonstandard and deprecated. | |
69 | - echo search $new_domain_name >> /etc/resolv.conf.dhclient | |
70 | - fi | |
71 | - for nameserver in $new_domain_name_servers; do | |
72 | - echo nameserver $nameserver >>/etc/resolv.conf.dhclient | |
73 | - done | |
74 | - | |
75 | - mv /etc/resolv.conf.dhclient /etc/resolv.conf | |
7cecd907 AM |
76 | - elif [ "x${new_dhcp6_name_servers}" != x ] ; then |
77 | - cat /dev/null > /etc/resolv.conf.dhclient6 | |
78 | - chmod 644 /etc/resolv.conf.dhclient6 | |
79 | - | |
80 | - if [ "x${new_dhcp6_domain_search}" != x ] ; then | |
81 | - echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 | |
82 | - fi | |
83 | - for nameserver in ${new_dhcp6_name_servers} ; do | |
84 | - echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 | |
85 | - done | |
86 | - | |
87 | - mv /etc/resolv.conf.dhclient6 /etc/resolv.conf | |
893aa178 JR |
88 | - fi |
89 | + if [ -n "$new_domain_name_servers" ]; then | |
90 | + :> /etc/resolv.conf.dhclient | |
91 | + chmod 644 /etc/resolv.conf.dhclient | |
92 | + if [ -n "$new_domain_search" ]; then | |
93 | + echo search $new_domain_search >> /etc/resolv.conf.dhclient | |
94 | + elif [ -n "$new_domain_name" ]; then | |
95 | + # Note that the DHCP 'Domain Name Option' is really just a domain | |
96 | + # name, and that this practice of using the domain name option as | |
97 | + # a search path is both nonstandard and deprecated. | |
98 | + echo search $new_domain_name >> /etc/resolv.conf.dhclient | |
99 | + fi | |
100 | + for nameserver in $new_domain_name_servers; do | |
101 | + echo nameserver $nameserver >>/etc/resolv.conf.dhclient | |
102 | + done | |
103 | + mv /etc/resolv.conf.dhclient /etc/resolv.conf | |
7cecd907 AM |
104 | + elif [ -n "${new_dhcp6_name_servers}" ] ; then |
105 | + :> /etc/resolv.conf.dhclient6 | |
106 | + chmod 644 /etc/resolv.conf.dhclient6 | |
107 | + | |
108 | + if [ "x${new_dhcp6_domain_search}" != x ] ; then | |
109 | + echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 | |
110 | + fi | |
111 | + for nameserver in ${new_dhcp6_name_servers} ; do | |
112 | + echo nameserver ${nameserver} >> /etc/resolv.conf.dhclient6 | |
113 | + done | |
114 | + mv /etc/resolv.conf.dhclient6 /etc/resolv.conf | |
893aa178 JR |
115 | + fi |
116 | } | |
117 | ||
118 | -# Must be used on exit. Invokes the local dhcp client exit hooks, if any. | |
119 | +# Must be used on exit. | |
120 | +# Invokes the local dhcp client exit hooks, if any. | |
121 | exit_with_hooks() { | |
122 | - exit_status=$1 | |
123 | - if [ -f /etc/dhclient-exit-hooks ]; then | |
124 | - . /etc/dhclient-exit-hooks | |
125 | - fi | |
126 | -# probably should do something with exit status of the local script | |
127 | - exit $exit_status | |
128 | + exit_status=$1 | |
129 | + if [ -f /etc/dhclient-exit-hooks ]; then | |
130 | + . /etc/dhclient-exit-hooks | |
131 | + fi | |
132 | + # probably should do something with exit status of the local script | |
133 | + exit $exit_status | |
134 | } | |
135 | ||
136 | # Invoke the local dhcp client enter hooks, if they exist. | |
137 | if [ -f /etc/dhclient-enter-hooks ]; then | |
138 | - exit_status=0 | |
139 | - . /etc/dhclient-enter-hooks | |
140 | - # allow the local script to abort processing of this state | |
141 | - # local script must set exit_status variable to nonzero. | |
142 | - if [ $exit_status -ne 0 ]; then | |
143 | - exit $exit_status | |
144 | - fi | |
7cecd907 AM |
145 | + exit_status=0 |
146 | + . /etc/dhclient-enter-hooks | |
147 | + # allow the local script to abort processing of this state | |
148 | + # local script must set exit_status variable to nonzero. | |
149 | + if [ $exit_status -ne 0 ]; then | |
150 | + exit $exit_status | |
151 | + fi | |
152 | fi | |
153 | ||
893aa178 JR |
154 | -release=`uname -r` |
155 | -release=`expr $release : '\(.*\)\..*'` | |
156 | -relminor=`echo $release |sed -e 's/[0-9]*\.\([0-9][0-9]*\)\(\..*\)*$/\1/'` | |
157 | -relmajor=`echo $release |sed -e 's/\([0-9][0-9]*\)\..*$/\1/'` | |
158 | - | |
7cecd907 AM |
159 | ### |
160 | ### DHCPv4 Handlers | |
161 | ### | |
162 | ||
893aa178 JR |
163 | -if [ x$new_broadcast_address != x ]; then |
164 | - new_broadcast_arg="broadcast $new_broadcast_address" | |
165 | -fi | |
166 | -if [ x$old_broadcast_address != x ]; then | |
167 | - old_broadcast_arg="broadcast $old_broadcast_address" | |
168 | -fi | |
169 | -if [ x$new_subnet_mask != x ]; then | |
170 | - new_subnet_arg="netmask $new_subnet_mask" | |
171 | -fi | |
172 | -if [ x$old_subnet_mask != x ]; then | |
173 | - old_subnet_arg="netmask $old_subnet_mask" | |
174 | -fi | |
175 | -if [ x$alias_subnet_mask != x ]; then | |
176 | - alias_subnet_arg="netmask $alias_subnet_mask" | |
177 | -fi | |
178 | - | |
179 | -if [ x$reason = xMEDIUM ]; then | |
180 | - # Linux doesn't do mediums (ok, ok, media). | |
181 | - exit_with_hooks 0 | |
182 | -fi | |
183 | - | |
184 | -if [ x$reason = xPREINIT ]; then | |
185 | - if [ x$alias_ip_address != x ]; then | |
186 | - # Bring down alias interface. Its routes will disappear too. | |
187 | - ifconfig $interface:0- inet 0 | |
188 | - fi | |
189 | - if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ) | |
190 | - then | |
191 | - ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \ | |
192 | - broadcast 255.255.255.255 up | |
193 | - # Add route to make broadcast work. Do not omit netmask. | |
194 | - route add default dev $interface netmask 0.0.0.0 | |
195 | - else | |
196 | - ifconfig $interface 0 up | |
197 | - fi | |
198 | - | |
199 | - # We need to give the kernel some time to get the interface up. | |
200 | - sleep 1 | |
201 | - | |
202 | - exit_with_hooks 0 | |
203 | -fi | |
204 | - | |
205 | -if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then | |
206 | - exit_with_hooks 0 | |
207 | -fi | |
208 | - | |
209 | -if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ | |
210 | - [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then | |
211 | - current_hostname=`hostname` | |
212 | - if [ x$current_hostname = x ] || \ | |
213 | - [ x$current_hostname = x$old_host_name ]; then | |
214 | - if [ x$current_hostname = x ] || \ | |
215 | - [ x$new_host_name != x$old_host_name ]; then | |
216 | - hostname $new_host_name | |
217 | - fi | |
218 | - fi | |
219 | - | |
220 | - if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \ | |
221 | - [ x$alias_ip_address != x$old_ip_address ]; then | |
222 | - # Possible new alias. Remove old alias. | |
223 | - ifconfig $interface:0- inet 0 | |
224 | - fi | |
225 | - if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]; then | |
226 | - # IP address changed. Bringing down the interface will delete all routes, | |
227 | - # and clear the ARP cache. | |
228 | - ifconfig $interface inet 0 down | |
229 | - | |
230 | - fi | |
231 | - if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \ | |
232 | - [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then | |
233 | - | |
234 | - ifconfig $interface inet $new_ip_address $new_subnet_arg \ | |
235 | - $new_broadcast_arg | |
236 | - # Add a network route to the computed network address. | |
237 | - if [ $relmajor -lt 2 ] || \ | |
238 | - ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then | |
239 | - route add -net $new_network_number $new_subnet_arg dev $interface | |
240 | - fi | |
241 | - for router in $new_routers; do | |
f1ddf01f AM |
242 | - if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
243 | - route add -host $router dev $interface | |
244 | - fi | |
893aa178 JR |
245 | - route add default gw $router |
246 | - done | |
247 | - fi | |
248 | - if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ]; | |
249 | - then | |
250 | - ifconfig $interface:0- inet 0 | |
251 | - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg | |
252 | - route add -host $alias_ip_address $interface:0 | |
253 | - fi | |
254 | - make_resolv_conf | |
255 | - exit_with_hooks 0 | |
256 | -fi | |
257 | - | |
258 | -if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \ | |
259 | - || [ x$reason = xSTOP ]; then | |
260 | - if [ x$alias_ip_address != x ]; then | |
261 | - # Turn off alias interface. | |
262 | - ifconfig $interface:0- inet 0 | |
263 | - fi | |
264 | - if [ x$old_ip_address != x ]; then | |
265 | - # Shut down interface, which will delete routes and clear arp cache. | |
266 | - ifconfig $interface inet 0 down | |
267 | - fi | |
268 | - if [ x$alias_ip_address != x ]; then | |
269 | - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg | |
270 | - route add -host $alias_ip_address $interface:0 | |
271 | - fi | |
272 | - exit_with_hooks 0 | |
7cecd907 AM |
273 | +if [ -n "$new_broadcast_address" ]; then |
274 | + new_broadcast_arg="broadcast $new_broadcast_address" | |
275 | fi | |
893aa178 JR |
276 | - |
277 | -if [ x$reason = xTIMEOUT ]; then | |
278 | - if [ x$alias_ip_address != x ]; then | |
279 | - ifconfig $interface:0- inet 0 | |
280 | - fi | |
281 | - ifconfig $interface inet $new_ip_address $new_subnet_arg \ | |
282 | - $new_broadcast_arg | |
283 | - set $new_routers | |
893aa178 JR |
284 | - if ping -q -c 1 $1; then |
285 | - if [ x$new_ip_address != x$alias_ip_address ] && \ | |
286 | - [ x$alias_ip_address != x ]; then | |
287 | - ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg | |
288 | - route add -host $alias_ip_address dev $interface:0 | |
289 | - fi | |
290 | - if [ $relmajor -lt 2 ] || \ | |
291 | - ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then | |
292 | - route add -net $new_network_number | |
293 | - fi | |
294 | - for router in $new_routers; do | |
f1ddf01f AM |
295 | - if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
296 | - route add -host $router dev $interface | |
297 | - fi | |
893aa178 JR |
298 | - route add default gw $router |
299 | - done | |
300 | - make_resolv_conf | |
301 | - exit_with_hooks 0 | |
302 | - fi | |
303 | - ifconfig $interface inet 0 down | |
304 | - exit_with_hooks 1 | |
893aa178 JR |
305 | +if [ -n "$old_broadcast_address" ]; then |
306 | + old_broadcast_arg="broadcast $old_broadcast_address" | |
7cecd907 AM |
307 | fi |
308 | - | |
309 | -### | |
310 | -### DHCPv6 Handlers | |
311 | -### | |
312 | - | |
313 | -if [ ${reason} = PREINIT6 ] ; then | |
314 | - # Ensure interface is up. | |
315 | - ${ip} link set ${interface} up | |
316 | - | |
317 | - # Remove any stale addresses from aborted clients. | |
318 | - ${ip} -f inet6 addr flush dev ${interface} scope global permanent | |
319 | - | |
320 | - exit_with_hooks 0 | |
893aa178 JR |
321 | +if [ -n "$new_subnet_mask" ]; then |
322 | + new_subnet_arg="$(calc_prefix $new_subnet_mask)" | |
7cecd907 | 323 | fi |
893aa178 JR |
324 | +if [ -n "$old_subnet_mask" ]; then |
325 | + old_subnet_arg="$(calc_prefix $old_subnet_mask)" | |
326 | +fi | |
327 | +if [ -n "$alias_subnet_mask" ]; then | |
328 | + alias_subnet_arg="$(calc_prefix $alias_subnet_mask)" | |
329 | +fi | |
330 | +[ -z "new_subnet_arg" ] && $new_subnet_arg="32" | |
331 | +[ -z "old_subnet_arg" ] && $old_subnet_arg="32" | |
332 | +[ -z "alias_subnet_arg" ] && $alias_subnet_arg="32" | |
333 | + | |
334 | +case "$reason" in | |
335 | + MEDIUM) | |
336 | + # Linux doesn't do mediums (ok, ok, media). | |
337 | + ;; | |
338 | + | |
339 | + PREINIT) | |
340 | + if [ -n "$alias_ip_address" ]; then | |
341 | + /sbin/ip addr del $alias_ip_address/$alias_subnet_arg dev $interface | |
342 | + fi | |
343 | + /sbin/ip link set $interface up | |
344 | + | |
345 | + # We need to give the kernel some time to get the interface up. | |
346 | + sleep 1 | |
347 | + ;; | |
348 | + | |
349 | + BOUND|RENEW|REBIND|REBOOT) | |
350 | + current_hostname=`hostname` | |
351 | + if [ -z "$current_hostname" ]; then | |
352 | + hostname $new_host_name | |
353 | + elif [ "$current_hostname" = "$old_host_name" -a \ | |
354 | + "$new_host_name" != "$old_host_name" ]; then | |
355 | + hostname $new_host_name | |
356 | + fi | |
357 | + | |
358 | + if [ -n "$old_ip_address" -a -n "$alias_ip_address" -a \ | |
359 | + "$alias_ip_address" != "$old_ip_address" ]; then | |
360 | + # Possible new alias. Remove old alias. | |
361 | + /sbin/ip addr del $alias_ip_address/$alias_subnet_arg dev $interface | |
362 | + fi | |
363 | + if [ -n "$old_ip_address" -a "$old_ip_address" != "$new_ip_address" ]; then | |
364 | + # IP address changed. | |
365 | + /sbin/ip addr del $old_ip_address/$old_subnet_arg dev $interface | |
366 | + for router in $old_routers; do | |
367 | + /sbin/ip route del default via $router | |
368 | + done | |
369 | + if [ -n "$old_static_routes" ]; then | |
370 | + set -- $old_static_routes | |
371 | + while [ $# -gt 1 ]; do | |
372 | + /sbin/ip route del $1 via $2 | |
373 | + shift; shift | |
374 | + done | |
375 | + fi | |
376 | + fi | |
377 | + if [ -z "$old_ip_address" -o "$old_ip_address" != "$new_ip_address" -o \ | |
378 | + "$reason" = "BOUND" -o "$reason" = "REBOOT" ]; then | |
379 | + /sbin/ip addr add $new_ip_address/$new_subnet_arg $new_broadcast_arg dev $interface | |
380 | + # Add a network route to the computed network address. | |
381 | + for router in $new_routers; do | |
f1ddf01f AM |
382 | + if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
383 | + /sbin/ip route add $router dev $interface | |
384 | + fi | |
893aa178 JR |
385 | + /sbin/ip route add default via $router |
386 | + done | |
387 | + if [ -n "$new_static_routes" ]; then | |
388 | + set -- $new_static_routes | |
389 | + while [ $# -gt 1 ]; do | |
390 | + /sbin/ip route add $1 via $2 | |
391 | + shift; shift | |
392 | + done | |
393 | + fi | |
394 | + fi | |
395 | + if [ -n "$alias_ip_address" -a "$new_ip_address" != "$alias_ip_address" ]; then | |
396 | + /sbin/ip addr add $alias_ip_address/$alias_subnet_arg dev $interface | |
397 | + fi | |
398 | + make_resolv_conf | |
399 | + ;; | |
400 | + | |
401 | + EXPIRE|FAIL|RELEASE|STOP) | |
402 | + if [ -n "$alias_ip_address" ]; then | |
403 | + # Turn off alias interface. | |
404 | + /sbin/ip addr del $alias_ip_address/$alias_subnet_arg dev $interface | |
405 | + fi | |
406 | + if [ -n "$old_ip_address" ]; then | |
407 | + /sbin/ip addr del $old_ip_address/$old_subnet_arg dev $interface | |
408 | + for router in $old_routers; do | |
409 | + /sbin/ip route del default via $router | |
410 | + done | |
411 | + if [ -n "$old_static_routes" ]; then | |
412 | + set -- $old_static_routes | |
413 | + while [ $# -gt 1 ]; do | |
414 | + /sbin/ip route del $1 via $2 | |
415 | + shift; shift | |
416 | + done | |
417 | + fi | |
418 | + fi | |
419 | + if [ -n "$alias_ip_address" ]; then | |
420 | + /sbin/ip addr add $alias_ip_address/$alias_subnet_arg dev $interface | |
421 | + fi | |
422 | + ;; | |
423 | + | |
424 | + TIMEOUT) | |
425 | + if [ -n "$alias_ip_address" ]; then | |
426 | + /sbin/ip addr del $alias_ip_address/$alias_subnet_arg dev $interface | |
427 | + fi | |
428 | + /sbin/ip addr add $new_ip_address/$new_subnet_arg $new_broadcast_arg dev $interface | |
429 | + | |
430 | + set $new_routers | |
431 | + if ping -q -c 1 $1; then | |
432 | + if [ "$new_ip_address" != "$alias_ip_address" ] && \ | |
433 | + [ -n "$alias_ip_address" ]; then | |
434 | + /sbin/ip addr add $alias_ip_address/$alias_subnet_arg dev $interface | |
435 | + fi | |
436 | + for router in $new_routers; do | |
f1ddf01f AM |
437 | + if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then |
438 | + /sbin/ip route add $router dev $interface | |
439 | + fi | |
893aa178 JR |
440 | + /sbin/ip route add default via $router |
441 | + done | |
442 | + if [ -n "$new_static_routes" ]; then | |
443 | + set -- $new_static_routes | |
444 | + while [ $# -gt 1 ]; do | |
445 | + /sbin/ip route add $1 via $2 | |
446 | + shift; shift | |
447 | + done | |
448 | + fi | |
449 | + make_resolv_conf | |
450 | + exit_with_hooks 0 | |
451 | + fi | |
452 | + | |
453 | + /sbin/ip addr del $new_ip_address/$new_subnet_arg dev $interface | |
454 | + for router in $old_routers; do | |
455 | + /sbin/ip route del default via $router | |
456 | + done | |
457 | + if [ -n "$old_static_routes" ]; then | |
458 | + set -- $old_static_routes | |
459 | + while [ $# -gt 1 ]; do | |
460 | + /sbin/ip route del $1 via $2 | |
461 | + shift; shift | |
462 | + done | |
463 | + fi | |
464 | + exit_with_hooks 1 | |
465 | + ;; | |
7cecd907 AM |
466 | + |
467 | + PREINIT6) | |
468 | + # Ensure interface is up. | |
469 | + /sbin/ip link set ${interface} up | |
470 | + | |
471 | + # Remove any stale addresses from aborted clients. | |
472 | + /sbin/ip -f inet6 addr flush dev ${interface} scope global permanent | |
473 | + | |
474 | + exit_with_hooks 0 | |
475 | + ;; | |
476 | + BOUND6) | |
477 | + if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then | |
478 | + exit_with_hooks 2; | |
479 | + fi | |
480 | ||
481 | -if [ ${reason} = BOUND6 ] ; then | |
482 | - if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then | |
483 | - exit_with_hooks 2; | |
484 | - fi | |
485 | - | |
486 | - ${ip} -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ | |
487 | + /sbin/ip -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ | |
488 | dev ${interface} scope global | |
489 | ||
490 | - # Check for nameserver options. | |
491 | - make_resolv_conf | |
492 | - | |
493 | - exit_with_hooks 0 | |
494 | -fi | |
495 | + # Check for nameserver options. | |
496 | + make_resolv_conf | |
497 | ||
498 | -if [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then | |
499 | - # Make sure nothing has moved around on us. | |
500 | + exit_with_hooks 0 | |
501 | + ;; | |
502 | ||
503 | - # Nameservers/domains/etc. | |
504 | - if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || | |
505 | - [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then | |
506 | - make_resolv_conf | |
507 | - fi | |
508 | - | |
509 | - exit_with_hooks 0 | |
510 | -fi | |
511 | + RENEW6|REBIND6) | |
512 | + # Make sure nothing has moved around on us. | |
513 | ||
514 | -if [ ${reason} = DEPREF6 ] ; then | |
515 | - if [ x${new_ip6_prefixlen} = x ] ; then | |
516 | - exit_with_hooks 2; | |
517 | - fi | |
518 | - | |
519 | - # There doesn't appear to be a way to update an addr to indicate | |
520 | - # preference. | |
521 | -# ${ip} -f inet6 addr ??? ${new_ip6_address}/${new_ip6_prefixlen} \ | |
522 | -# dev ${interface} scope global deprecated? | |
523 | + # Nameservers/domains/etc. | |
524 | + if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] || | |
525 | + [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then | |
526 | + make_resolv_conf | |
527 | + fi | |
528 | + | |
529 | + exit_with_hooks 0 | |
530 | + ;; | |
531 | + | |
532 | + DEPREF6) | |
533 | + if [ x${new_ip6_prefixlen} = x ] ; then | |
534 | + exit_with_hooks 2; | |
535 | + fi | |
536 | + | |
537 | + # There doesn't appear to be a way to update an addr to indicate | |
538 | + # preference. | |
539 | + # /sbin/ip -f inet6 addr ??? ${new_ip6_address}/${new_ip6_prefixlen} \ | |
540 | + # dev ${interface} scope global deprecated? | |
541 | + | |
542 | + exit_with_hooks 0 | |
543 | + ;; | |
544 | + | |
545 | + EXPIRE6|RELEASE6|STOP6) | |
546 | + if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then | |
547 | + exit_with_hooks 2; | |
548 | + fi | |
549 | ||
550 | - exit_with_hooks 0 | |
551 | -fi | |
552 | - | |
553 | -if [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then | |
554 | - if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then | |
555 | - exit_with_hooks 2; | |
556 | - fi | |
557 | - | |
558 | - ${ip} -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \ | |
559 | + /sbin/ip -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \ | |
560 | dev ${interface} | |
561 | ||
562 | - exit_with_hooks 0 | |
563 | -fi | |
564 | + exit_with_hooks 0 | |
565 | + ;; | |
566 | + | |
893aa178 JR |
567 | + *) |
568 | + ;; | |
569 | +esac | |
570 | ||
571 | exit_with_hooks 0 |