3 .
/usr
/lib
/network
/functions
6 LOG_FACILITY
="dhclient-script"
11 assert device_exists
${interface}
13 basename="$(basename $0)"
14 log DEBUG
"${basename} called for interface=${interface} reason=${reason}"
19 # Linux does not handle MEDIUM.
24 # Bring up the device if it hasn't been done before.
25 if ! device_is_up
${interface}; then
26 log DEBUG
"The interface '${interface}' does not appear to be up."
31 # If the use configured a delay, we will honour that.
32 if [ -n "${DELAY}" ]; then
33 assert isinteger DELAY
36 # If he didn't, we will try to detect is STP has brought the
38 elif device_is_bridge
${interface}; then
41 while [ ${counter} -gt 0 ]; do
42 # We may end this, when the bridge is in forwarding mode.
43 if bridge_is_forwarding
${interface}; then
44 log DEBUG
"Bridge '${interface}' is in forwarding mode."
48 counter
=$
(( ${counter} - 1 ))
52 # Tell the daemon, that we are not ready to go on.
53 if [ ${counter} -eq 0 ]; then
54 log ERROR
"Bridge '${interface}' is not in forwarding mode."
55 log ERROR
"Could not go on with getting a DHCP lease. Exiting."
65 BOUND|RENEW|REBIND|REBOOT
)
66 # Check if the IP address has changed. If so, delete all routes and stuff.
67 if [ -n "${old_ip_address}" -a "${old_ip_address}" != "${new_ip_address}" ]; then
68 ipv4_flush_device
${interface}
73 if [ ! "${old_ip_address}" = "${new_ip_address}" ] || \
74 [ ! "${old_subnet_mask}" = "${new_subnet_mask}" ] || \
75 [ ! "${old_network_number}" = "${new_network_number}" ] || \
76 [ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] || \
77 [ ! "${old_routers}" = "${new_routers}" ] || \
78 [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
81 # Calc a prefix out of address and subnet mask.
82 new_prefix
="$(ipv4_get_prefix ${new_ip_address} ${new_subnet_mask})"
84 # Set the new ip address.
85 ip_address_add
${interface} ${new_ip_address}/${new_prefix}
86 device_set_up
${interface}
89 # A MTU of 576 is used for X.25 and dialup connections. Some broken DHCP
90 # servers send out an MTU of 576 bytes, which will be ignored.
91 if [ -n "${new_interface_mtu}" ] && [ ${new_interface_mtu} -gt 576 ]; then
92 device_set_mtu
${interface} ${new_interface_mtu}
96 routing_db_set
${interface} ipv4
type "ipv4-dhcp"
97 routing_db_set
${interface} ipv4 local-ip-address "${new_ip_address}/${new_prefix}"
98 routing_db_set ${interface} ipv4 remote-ip-address "${new_routers}"
99 routing_db_set ${interface} ipv4 active 1
100 routing_db_set ${interface} ipv4 domain-name "${new_domain_name}"
101 routing_db_set ${interface} ipv4 domain-name-servers "${new_domain_name_servers}"
102 routing_db_set ${interface} ipv4 domain-name-servers-priority "${DNS_SERVER_DYNAMIC_PRIORITY}"
104 # Update the routing tables.
105 routing_update ${interface} ipv4
106 routing_default_update
109 dns_generate_resolvconf
117 EXPIRE|FAIL|RELEASE|STOP)
118 # Remove the currently configured addresses from the device.
119 if [ -n "${old_ip_address}" ]; then
120 ipv4_flush_device ${interface}
123 routing_db_remove ${interface} ipv4
124 routing_default_update