4 if [ x
"$new_domain_name_servers" != x
]; then
5 cat /dev
/null
> /etc
/resolv.conf.dhclient
6 chmod 644 /etc
/resolv.conf.dhclient
7 if [ x
"$new_domain_search" != x
]; then
8 echo search
$new_domain_search >> /etc
/resolv.conf.dhclient
9 elif [ x
"$new_domain_name" != x
]; then
10 # Note that the DHCP 'Domain Name Option' is really just a domain
11 # name, and that this practice of using the domain name option as
12 # a search path is both nonstandard and deprecated.
13 echo search
$new_domain_name >> /etc
/resolv.conf.dhclient
15 for nameserver
in $new_domain_name_servers; do
16 echo nameserver
$nameserver >>/etc
/resolv.conf.dhclient
19 elif [ "x${new_dhcp6_name_servers}" != x
] ; then
20 cat /dev
/null
> /etc
/resolv.conf.dhclient6
21 chmod 644 /etc
/resolv.conf.dhclient6
23 if [ "x${new_dhcp6_domain_search}" != x
] ; then
24 echo search
${new_dhcp6_domain_search} >> /etc
/resolv.conf.dhclient6
26 for nameserver
in ${new_dhcp6_name_servers} ; do
27 echo nameserver
${nameserver} >> /etc
/resolv.conf.dhclient6
31 # if both v4 and v6 clients are running, concatenate results
32 cat /etc
/resolv.conf.
* > /etc
/resolv.conf
35 # Must be used on exit. Invokes the local dhcp client exit hooks, if any.
38 if [ -f /etc
/dhclient-exit-hooks
]; then
39 .
/etc
/dhclient-exit-hooks
41 # probably should do something with exit status of the local script
45 # Invoke the local dhcp client enter hooks, if they exist.
46 if [ -f /etc
/dhclient-enter-hooks
]; then
48 .
/etc
/dhclient-enter-hooks
49 # allow the local script to abort processing of this state
50 # local script must set exit_status variable to nonzero.
51 if [ $exit_status -ne 0 ]; then
60 if [ x
$new_broadcast_address != x
]; then
61 new_broadcast_arg
="broadcast $new_broadcast_address"
63 if [ x
$new_subnet_mask != x
]; then
64 new_subnet_arg
="netmask $new_subnet_mask"
66 if [ x
$alias_subnet_mask != x
]; then
67 alias_subnet_arg
="netmask $alias_subnet_mask"
70 if [ x
$reason = xMEDIUM
]; then
71 # Linux doesn't do mediums (ok, ok, media).
75 if [ x
$reason = xPREINIT
]; then
76 if [ x
$alias_ip_address != x
]; then
77 # Bring down alias interface. Its routes will disappear too.
78 ifconfig
$interface:0- 0.0.0.0
80 ifconfig
$interface 0.0.0.0 up
82 # We need to give the kernel some time to get the interface up.
88 if [ x
$reason = xARPCHECK
] ||
[ x
$reason = xARPSEND
]; then
92 if [ x
$reason = xBOUND
] ||
[ x
$reason = xRENEW
] || \
93 [ x
$reason = xREBIND
] ||
[ x
$reason = xREBOOT
]; then
94 current_hostname
=`hostname`
95 if [ x
$current_hostname = x
] || \
96 [ x
$current_hostname = x
$old_host_name ]; then
97 if [ x
$current_hostname = x
] || \
98 [ x
$new_host_name != x
$old_host_name ]; then
99 hostname
$new_host_name
103 if [ x
$old_ip_address != x
] && [ x
$alias_ip_address != x
] && \
104 [ x
$alias_ip_address != x
$old_ip_address ]; then
105 # Possible new alias. Remove old alias.
106 ifconfig
$interface:0- 0.0.0.0
108 if [ x
$old_ip_address != x
] && [ x
$old_ip_address != x
$new_ip_address ]; then
109 # IP address changed. Bringing down the interface will delete all routes,
110 # and clear the ARP cache.
111 ifconfig
$interface 0.0.0.0 down
114 if [ x
$old_ip_address = x
] ||
[ x
$old_ip_address != x
$new_ip_address ] || \
115 [ x
$reason = xBOUND
] ||
[ x
$reason = xREBOOT
]; then
117 ifconfig
$interface $new_ip_address $new_subnet_arg \
119 for router
in $new_routers; do
120 if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
121 route add
-host $router dev
$interface
123 route add default gw
$router
126 if [ x
$new_ip_address != x
$alias_ip_address ] && [ x
$alias_ip_address != x
];
128 ifconfig
$interface:0- 0.0.0.0
129 ifconfig
$interface:0 $alias_ip_address $alias_subnet_arg
130 route add
-host $alias_ip_address $interface:0
136 if [ x
$reason = xEXPIRE
] ||
[ x
$reason = xFAIL
] ||
[ x
$reason = xRELEASE
] \
137 ||
[ x
$reason = xSTOP
]; then
138 if [ x
$alias_ip_address != x
]; then
139 # Turn off alias interface.
140 ifconfig
$interface:0- 0.0.0.0
142 if [ x
$old_ip_address != x
]; then
143 # Shut down interface, which will delete routes and clear arp cache.
144 ifconfig
$interface 0.0.0.0 down
146 if [ x
$alias_ip_address != x
]; then
147 ifconfig
$interface:0 $alias_ip_address $alias_subnet_arg
148 route add
-host $alias_ip_address $interface:0
151 # remove v4 dns configuration for this interface
152 rm /etc
/resolv.conf.dhclient
153 cat /etc
/resolv.conf.
* > /etc
/resolv.conf
158 if [ x
$reason = xTIMEOUT
]; then
159 if [ x
$alias_ip_address != x
]; then
160 ifconfig
$interface:0- 0.0.0.0
162 ifconfig
$interface $new_ip_address $new_subnet_arg \
165 if ping -q -c 1 $1; then
166 if [ x
$new_ip_address != x
$alias_ip_address ] && \
167 [ x
$alias_ip_address != x
]; then
168 ifconfig
$interface:0 $alias_ip_address $alias_subnet_arg
169 route add
-host $alias_ip_address dev
$interface:0
171 for router
in $new_routers; do
172 if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
173 route add
-host $router dev
$interface
175 route add default gw
$router
180 ifconfig
$interface 0.0.0.0 down
188 if [ x
$reason = xPREINIT6
]; then
189 # Ensure interface is up.
190 ifconfig
${interface} up
192 # Remove any stale addresses from aborted clients.
193 ip
-f inet6 addr flush dev
${interface} scope global
198 if [ x
${old_ip6_prefix} != x
] ||
[ x
${new_ip6_prefix} != x
] ; then
199 echo Prefix
${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
204 if [ x
$reason = xBOUND6
]; then
205 if [ x
${new_ip6_address} = x
] ||
[ x
${new_ip6_prefixlen} = x
] ; then
209 ifconfig
${interface} add ${new_ip6_address}/${new_ip6_prefixlen}
211 # Check for nameserver options.
215 # Set up softwire tunnel
216 if [ x
${new_dhcp6_softwire} != x
] ; then
217 /etc
/init.d
/dhclient stop
218 ifconfig
${interface} 0.0.0.0
219 ip
-6 tunnel add tun0 mode ipip6 \
220 remote
${new_dhcp6_softwire} \
221 local ${new_ip6_address} \
222 dev
${interface} encaplimit none
224 ip route add default dev tun0
231 if [ x
$reason = xRENEW6
] ||
[ x
$reason = xREBIND6
]; then
232 if [ x
${new_ip6_address} = x
] ||
[ x
${new_ip6_prefixlen} = x
] ; then
236 ifconfig
${interface} add ${new_ip6_address}/${new_ip6_prefixlen}
238 # Make sure nothing has moved around on us.
240 # Nameservers/domains/etc.
241 if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
242 [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
249 if [ x
$reason = xDEPREF6
]; then
250 if [ x
${new_ip6_address} = x
] ; then
254 # Busybox ifconfig has no way to communicate this to the kernel, so ignore it
259 if [ x
$reason = xEXPIRE6
-o x
$reason = xRELEASE6
-o x
$reason = xSTOP6
]; then
260 if [ x
${old_ip6_address} = x
] ||
[ x
${old_ip6_prefixlen} = x
] ; then
264 ifconfig
${interface} del ${old_ip6_address}/${old_ip6_prefixlen}
266 # remove v6 dns configuration for this interface
267 rm /etc
/resolv.conf.dhclient6
268 cat /etc
/resolv.conf.
* > /etc
/resolv.conf
271 # Tear down softwire tunnel
272 if [ x
${old_dhcp6_softwire} != x
] ; then
273 ip link
set tun0 down