Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In gentoo, this is as simple as:

dhcp_ethX="nodns nogateway"

How should I go about this in the interfaces file?

share|improve this question
What do you want, set them statically or use the current values? – chmeee Jun 21 '09 at 14:53
I want to configure interface via DHCP, but ignore the given dns and gateway settings, this is for multiple uplink configuration. – Karolis T. Jun 21 '09 at 15:16
up vote 9 down vote accepted

edit /etc/dhcp3/dhclient.conf

check the line:

#prepend domain-name-servers;

and uncomment it and set whatever dns servers you want to use

then in the request section below there will be something like this:

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, host-name,
        netbios-name-servers, netbios-scope, interface-mtu;

remove domain-name-servers and routers, that should remove the dns server and router/gateway requests via dhcp

share|improve this answer
Wouldn't it be better to use supersede instead of prepend? Because if the DHCP server would reply with DNS servers despite you don't request them, they would still be used (just prepended). – gertvdijk Jul 14 at 22:42

While not doing exactly what you've asked for, the ifmetric package may provide a better solution.

sudo aptitude install ifmetric

Then in your /etc/network/interfaces file assign metrics to your interfaces. Note that not having a metric is the same as having a zero metric.

allow-hotplug eth0
iface eth0 inet dhcp
    metric 1

allow-hotplug eth1
iface eth1 inet dhcp

The above makes it so that when eth1 is plugged in, its routes will take precedence over routes from eth0. This may be better because you allow the routes to failover, so that it will still have a default route even if the eth1 interface is unplugged.

This doesn't affect dns settings, so depending on exactly what you want you may still have to uncomment and amend the line in /etc/dhcp3/dhclient.conf:

#prepend domain-name-servers;

and remove domain-name-servers from the request list that immediately follows.

share|improve this answer
Quite a neat little trick, thanks. – sleepycal May 14 '14 at 12:20

I don't think there's an exactly analagous command for /etc/network/interfaces; you'll have to set things up the way you like via the post-up command, most likely.

share|improve this answer

If you control the DHCP server then set the settings you want for this specific host based on the MAC address, otherwise setting a post-up script in /etc/network/interfaces is probably the simplest option

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.