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


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.

  • I don't know about the DNS side of it, but you could just assign a default static route with a low metric. It'll use that in preference to everything else.
    – hookenz
    Mar 11, 2015 at 22:18
  • 1
    I don't know the default route in advance. I am getting this information from the DHCP service on say eth0. Mar 11, 2015 at 22:28
  • Well if you happened to know what networks you were connecting to then you could do that. I was assuming they were well known private networks. Is that not the case? in Linux, you can have more than one uplink, more than one default route and this is OK.
    – hookenz
    Mar 11, 2015 at 22:47
  • 1
    Networks are not well known (to us), not under our control, and might change over time without notice. Added this to the question. Mar 11, 2015 at 23:30

5 Answers 5


(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.


  • 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
  • why don't you try it first?
    – hookenz
    Mar 11, 2015 at 22:18
  • I am contemplating this issue for a while. Writing it down gave me an idea, but unfortunately i cannot test before next week. Should i not post this idea until i tested it? But fair enough, i removed my request for others to confirm, that's a bit lazy. Mar 11, 2015 at 22:27
  • @NilsToedtmann, so did it work? Aug 19, 2016 at 6:34
  • dhclient was designed to serve multiple interfaces from one process (although I rarely see it used that way). Going with this approach results in every dhclient process "knowing" about eth0, and hence trying to obtain an address for it. For me (desktop environment), that's a blocker, though it might not be in an embedded box. YMMV and stuff.
    – Kees-Jan
    Nov 26, 2017 at 12:57
  • Additionally, you will need to explicitly specify each interface for which you want the "normal" behaviour, instead of each interface for which you want ignore default routes. In an environment where devices are added/removed dynamically, that might be undesirable
    – Kees-Jan
    Nov 26, 2017 at 12:59

Instead of using inet dhcp you can use inet manual to then specify your own dhclient call to which you can pass a custom dhclient.conf file (note the -cf <file> argument):

iface eth0 inet manual
    up /sbin/dhclient -4 -v -pf /run/dhclient.${IFACE}.pid \
        -lf /var/lib/dhcp/dhclient.${IFACE}.leases -I \
        -df /var/lib/dhcp/dhclient6.${IFACE}.leases \
        -cf /etc/dhcp/dhclient_no_routers.conf ${IFACE}
    down /sbin/dhclient -4 -v -r -pf /run/dhclient.${IFACE}.pid \
        -lf /var/lib/dhcp/dhclient.${IFACE}.leases -I \
        -df /var/lib/dhcp/dhclient6.${IFACE}.leases \
        -cf /etc/dhcp/dhclient_no_routers.conf ${IFACE}

In your custom dhclient.conf (/etc/dhcp/dhclient_no_routers.conf in this case) you can then set your desired DHCP options.

To see what else the inet dhcp method does, see the inet.defn file in the source code (that's where I got some of the dhclient call from above from).

  • Nifty idea, but it still is not "/etc/network/interfaces-only" as it requires a config file for the DHCP cllient. Hence I don't consider it an improvement over my solution. If dhclient could be entirely configured on its command line with no config file, one could do that, but looking at linux.die.net/man/8/dhclient that doesn't seem possible. Jan 17, 2018 at 10:57

Same problem solves by adding to /etc/dhcp/dhcliet.conf:

interface "eth0" {
    prepend domain-search "my.domain";
    prepend domain-name-servers; # for using dnsmasq without -r option
    request subnet-mask, broadcast-address, time-offset, 
            routers, domain-name-servers, domain-name, domain-search, host-name,
            dhcp6.name-servers, dhcp6.domain-search,
            netbios-name-servers, netbios-scope, interface-mtu,
            rfc3442-classless-static-routes, ntp-servers,
            dhcp6.fqdn, dhcp6.sntp-servers;
    require routers, domain-name-servers, domain-name, domain-search, host-name;


and remove global parameter request from config

  • If you remove the global request altogether, how do the other interfaces get configured properly (e.g. mask, broadcast, MTU, static routes etc)? Nov 27, 2017 at 16:29

(turning my earlier comments into an answer)


Adding a script as proposed below does result in a working initial situation. However, there are scenarios (for example disconnecting and then connecting the cable) where dhclient will happily re-add the default route, and the script will not run so it won't be deleted again. As a result, you will have two default routes.

Long story short: This approach (unfortunately) doesn't work.

Old answer - ignore this

Mucking around in dhclient.conf has two drawbacks for me

  • I have to specify each interface for which I want "normal" behavior, instead of specifying for which interface I want to ignore the defaults
  • isc dhclient (tried 4.3.3) will attempt to obtain an address for each interface it "knows about", and specifying interfaces in dhclient.conf causes it to "know about" that interface (see the documentation for the "interface" keyword in the dhclient.conf manpage). Since network manager and ifup/down expect dhclient to only obtain an address for the interface given on the command line, that results in confusing behavior.

Hence I chose for a script in /etc/network/if-up.d:


if [ x"$IFACE" = x"enp7s4" ]
    route del default enp7s4

Drawback: Since this is run after the interface is actually up, there will be a (brief) period if time where packets possibly go in the wrong direction. Well-designed applications should be able to deal with packets getting lost, so that should not be a problem :-). If you do not want any packets to leak into the wrong network, you'll need a firewall rule to block them.

  • Hmpf... Rereading the question this doesn't yet deal with DNS, so it's not a full answer...
    – Kees-Jan
    Nov 26, 2017 at 13:13
  • On my Debian 7 (and I guess same for Ubuntu and later Debians) dhclient refuses to add a 2nd default route. So you end up with whichever dhclient is faster Nov 27, 2017 at 16:25
  • And if the 2nd default route would get added, what happens when the lease is renewed? Would the previously deleted route get ge-added? Nov 27, 2017 at 16:26
  • For me (Ubuntu 16.04), dhclient happily adds a second default route. When the lease is renewed, I'd expect either nothing to happen, or a full ifdown/ifup cycle, causing any new default route to be deleted again.
    – Kees-Jan
    Dec 2, 2017 at 14:51

systemd ignores dhclient.conf. For anyone needing to do the same thing using systemd, if you add the following to all network interfaces files (/etc/systemd/network/*.network) for interfaces that you don't want to have using DNS or routing it also solves the issue:


As long as RouteMetric is greater than the metric of your primary route the gateway will not be used as long as the primary route is available. In my setup I increment it for each interface, so that traffic is always routed through the first available interface.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .