5
# reduced dhclient-script for the Debian installer
6
# changes by Joshua Kwan <joshk@triplehelix.org>,
7
# Bastian Blank <waldi@debian.org>
9
# dhclient-script for Linux. Dan Halbert, March, 1997.
10
# Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
11
# Modified for Debian. Matt Zimmerman and Eloy Paris, December 2003
14
if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then
15
local new_resolv_conf=/etc/resolv.conf.dhclient-new
16
rm -f $new_resolv_conf
17
if [ -n "$new_domain_name" ]; then
18
echo "search $new_domain_name" >>$new_resolv_conf
20
for nameserver in $new_domain_name_servers; do
21
echo "nameserver $nameserver" >>$new_resolv_conf
23
mv $new_resolv_conf /etc/resolv.conf
28
local current_hostname=$(cat /proc/sys/kernel/hostname)
29
if [ -z "$current_hostname" ] || [ "$current_hostname" = "(none)" ]; then
30
echo "$new_host_name" > /proc/sys/kernel/hostname
34
if [ -n "$new_subnet_mask" ]; then
35
new_mask="/$(ptom $new_subnet_mask)"
37
if [ -n "$old_subnet_mask" ]; then
38
old_mask="/$(ptom $old_subnet_mask)"
41
if [ -n "$new_broadcast_address" ]; then
42
new_broadcast_arg="broadcast $new_broadcast_address"
44
if [ -n "$old_broadcast_address" ]; then
45
old_broadcast_arg="broadcast $old_broadcast_address"
48
# Execute the operation
50
MEDIUM|ARPCHECK|ARPSEND)
54
ip link set $interface up
56
# We need to give the kernel some time to get the interface up.
59
BOUND|RENEW|REBIND|REBOOT)
63
if [ -n "$old_ip_address" ] && \
64
[ "$old_ip_address" != "$new_ip_address" ]; then
65
# IP address changed. Bringing down the interface will delete all routes,
66
# and clear the ARP cache.
67
ip addr del $old_ip_address$old_mask $old_broadcast_arg dev $interface
68
ip link set $interface down
71
if [ -n "$new_interface_mtu" ]; then
72
ip link set $interface mtu $new_interface_mtu || true
75
if [ -z "$old_ip_address" ] || [ "$old_ip_address" != "$new_ip_address" ] || \
76
[ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
78
ip link set $interface up
79
ip addr flush dev $interface
80
ip addr add $new_ip_address$new_mask $new_broadcast_arg dev $interface
82
for router in $new_routers; do
83
ip route add default via $router
89
# Get the domain name into a file suitable for netcfg to read.
90
printf "$new_domain_name" > /tmp/domain_name
92
if [ -n "$new_ntp_servers" ]; then
93
printf "$new_ntp_servers" > /tmp/dhcp-ntp-servers
98
EXPIRE|FAIL|RELEASE|STOP)
99
if [ -n "$old_ip_address" ]; then
100
# Shut down interface, which will delete routes and clear arp cache.
101
ip addr flush dev $interface
102
ip link set $interface down
108
ip link set $interface down