Ubuntu – Multiple DHCP uplinks – How to ignore DNS and default route on all but one

debiandhcpnetworkingUbuntu

A multi-homed box needs more than one uplink to be configured for DHCP. It needs to ignore default-route and DNS for all but one DHCP uplink.

There is a similar question here [ Debian interfaces file – ignore gateway and dns entries from dhcp ], but the answers there do not solve my problem:

  • Editing the global DHCP client configuration (/etc/dhcp[3]/dhclient.conf) would result in default-route and DNS being ignored on all DHCP uplinks.
  • The ifmetric suggestion only deals with the route, not with DNS.

Also, i hope that things have changed since 2009.

Note that i am talking headless embedded systems. NetworkManager is not an option.

Preferred solution would be /etc/network/interfaces{.d/} only. I am looking for something like this:

auto  eth0
iface eth0 inet dhcp

auto  eth1
iface eth1 inet dhcp
    ignore-dhcp-option routers domain-name-servers domain-name

Addendum:

We have dozens of these boxes installed in various environments. The networks are not under our control. In some cases, the boxes need to do DHCP on more than one interface. Default route and DNS are usually not known to us beforehand, and even if they were they might change over time without notice. Hence we can't set them statically but must configure them via the 'main' DHCP client.

Best Answer

(I am still interested in solutions that only touch /etc/network/interfaces{,.d/}, but not /etc/dhcp/. In the absence of such solutions, I use this one.)

In /etc/dhcp*/dhclient.conf, remove the options routers, domain-name-servers, domain-name, domain-search from the global request statement. Then add this (assuming eth0 is the device where default route and DNS shall not get ignored):

interface "eth0" {
    also request routers, domain-name-servers, domain-name, domain-search;
}

This solution works at least for isc-dhcp-client version 4.2.2.dfsg.1-5+deb70u8 as it is shipped with Debian 7. I assume it works for later versions too.


Edit:

  • Confirmed that the original idea works with minor changes (eth0 must be quoted, and it should be request, not required)
  • Specified the dlclient version this works for