dhclient fails setting default gateway to unreachable host

Bug #1737663 reported by HonoredMule
6
This bug affects 1 person
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} \
        ${if_metric:+metric $if_metric} >/dev/null 2>&1

  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/dhclient-enter-hooks.d, dumping variables.
    reason='BOUND'
    interface='eth0'
    new_ip_address='123.45.114.112'
    new_network_number='123.45.114.0'
    new_subnet_mask='255.255.255.0'
    new_broadcast_address='123.45.114.255'
    new_routers='123.45.112.1'
    new_domain_name='redacted.com'
    new_domain_name_servers='127.0.0.1'
    old_ip_address='123.45.114.112'
    old_network_number='123.45.114.0'
    old_subnet_mask='255.255.255.0'
    old_broadcast_address='123.45.114.255'
    old_routers='123.45.112.1'
    old_domain_name='redacted.com'
    old_domain_name_servers='127.0.0.1'

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
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.