6

In gentoo, this is as simple as:

dhcp_ethX="nodns nogateway"

How should I go about this in the interfaces file?

2
  • What do you want, set them statically or use the current values?
    – chmeee
    Jun 21, 2009 at 14:53
  • 1
    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, 2009 at 15:16

4 Answers 4

11

edit /etc/dhcp3/dhclient.conf

check the line:

#prepend domain-name-servers 127.0.0.1;

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

1
  • 1
    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, 2016 at 22:42
5

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 127.0.0.1;

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

0
0

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.

0

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

You must log in to answer this question.

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