3 .
/usr
/lib
/network
/functions
6 LOG_FACILITY
="dhclient-script"
10 assert isset interface
13 assert device_exists
${interface}
15 basename="$(basename $0)"
16 log DEBUG
"${basename} called for interface=${interface} reason=${reason}"
21 # Linux does not handle MEDIUM.
26 # Bring up the device if it hasn't been done before.
27 if ! device_is_up
${interface}; then
28 log DEBUG
"The interface '${interface}' does not appear to be up."
33 # If the use configured a delay, we will honour that.
34 if [ -n "${DELAY}" ]; then
35 assert isinteger DELAY
38 # If he didn't, we will try to detect is STP has brought the
40 elif device_is_bridge
${interface}; then
43 while [ ${counter} -gt 0 ]; do
44 # We may end this, when the bridge is in forwarding mode.
45 if bridge_is_forwarding
${interface}; then
46 log DEBUG
"Bridge '${interface}' is in forwarding mode."
50 counter
=$
(( ${counter} - 1 ))
54 # Tell the daemon, that we are not ready to go on.
55 if [ ${counter} -eq 0 ]; then
56 log ERROR
"Bridge '${interface}' is not in forwarding mode."
57 log ERROR
"Could not go on with getting a DHCP lease. Exiting."
67 BOUND|RENEW|REBIND|REBOOT
)
68 # Check if the IP address has changed. If so, delete all routes and stuff.
69 if [ -n "${old_ip_address}" -a "${old_ip_address}" != "${new_ip_address}" ]; then
70 ipv4_flush_device
${interface}
75 if [ ! "${old_ip_address}" = "${new_ip_address}" ] || \
76 [ ! "${old_subnet_mask}" = "${new_subnet_mask}" ] || \
77 [ ! "${old_network_number}" = "${new_network_number}" ] || \
78 [ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] || \
79 [ ! "${old_routers}" = "${new_routers}" ] || \
80 [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
83 # Calc a prefix out of address and subnet mask.
84 new_prefix
="$(ipv4_get_prefix ${new_ip_address} ${new_subnet_mask})"
86 # Set the new ip address.
87 ip_address_add
${interface} ${new_ip_address}/${new_prefix}
88 device_set_up
${interface}
91 # A MTU of 576 is used for X.25 and dialup connections. Some broken DHCP
92 # servers send out an MTU of 576 bytes, which will be ignored.
93 if [ -n "${new_interface_mtu}" ] && [ ${new_interface_mtu} -gt 576 ]; then
94 device_set_mtu
${interface} ${new_interface_mtu}
98 routing_db_set
${interface} ipv4
type "ipv4-dhcp"
99 routing_db_set
${interface} ipv4 local-ip-address "${new_ip_address}/${new_prefix}"
100 routing_db_set ${interface} ipv4 remote-ip-address "${new_routers}"
101 routing_db_set ${interface} ipv4 active 1
102 routing_db_set ${interface} ipv4 domain-name "${new_domain_name}"
103 routing_db_set ${interface} ipv4 domain-name-servers "${new_domain_name_servers}"
104 routing_db_set ${interface} ipv4 domain-name-servers-priority "${DNS_SERVER_DYNAMIC_PRIORITY}"
106 # Update the routing tables.
107 routing_update ${interface} ipv4
108 routing_default_update
111 dns_generate_resolvconf
119 EXPIRE|FAIL|RELEASE|STOP)
120 # Remove the currently configured addresses from the device.
121 if [ -n "${old_ip_address}" ]; then
122 ipv4_flush_device ${interface}
125 routing_db_remove ${interface} ipv4
126 routing_default_update