dhclient fails setting default gateway to unreachable host
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
isc-dhcp (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
When receiving an IP from a DHCP server and a router IP that is not the same IP, dhclient-script silently fails to add the router as a default route for the interface (RTNETLINK answers: Network is unreachable). Error occurs on line 320:
# set default route
ip -4 route add default via ${router} dev ${interface} \
With no control over the DHCP server (an ISP-provided appliance configured to propagate its external IP to this DHCP client), the apparent solution (other than quick hard-coded hacks like `route add default MYINTERFACE`) is to first create a single-ip route, adding the preceding line:
ip -4 route add ${router} dev ${interface}
(Alternatively, collapsing the resulting two rules by replacing original line's use of ${router} with ${new_ip_address} also works, and also preserves the route table's resolution of the gateway ip to a hostname - unlike the hack.)
I could probably write a more complex custom enter hook to correctly handle the scenario, but this does not seem so terribly obscure to justify it (standard appliance from a major Canadian ISP). With sufficient information present to infer the correct routing, I believe it should work out of the box.
I do not rule out consequences of doing so beyond my current grasp, and it does seem odd to me that my ISP provides a gateway outside the subnet. Nevertheless I hope some attention on the issue will yeild a more robust stock configuration or at least some deeper insight.
(Sanitized) variable dump for dhclient-script:
Tue Dec 12 00:59:23 AST 2017: entering /etc/dhcp/
reason='BOUND'
interface=
new_
new_
new_
new_
new_
new_
new_
old_
old_
old_
old_
old_
old_
old_
Routing rules with stock configuration (the only one that doesn't route internet traffic):
Destination Gateway Genmask Flags Metric Ref Use Iface
123.45.114.0 * 255.255.255.0 U 0 0 0 eth0
With my added line:
Destination Gateway Genmask Flags Metric Ref Use Iface
default fctnnbsc38w-123 0.0.0.0 UG 0 0 0 eth0
fctnnbsc38w-123 * 255.255.255.255 UH 0 0 0 eth0
123.45.114.0 * 255.255.255.0 U 0 0 0 eth0
With interface ip as router ip:
Destination Gateway Genmask Flags Metric Ref Use Iface
default fctnnbsc38w-123 0.0.0.0 UG 0 0 0 eth0
123.45.114.0 * 255.255.255.0 U 0 0 0 eth0
With hardcoded hack:
Destination Gateway Genmask Flags Metric Ref Use Iface
default * 0.0.0.0 U 0 0 0 eth0
123.45.114.0 * 255.255.255.0 U 0 0 0 eth0
description: | updated |
description: | updated |
description: | updated |