Debian – How to specify which DHCP server to get the name server from

debiandhcpnameservernetworking

I'm using Debian Lenny with two ethernet network cards, one plugged into a different network. My goal was to set both interfaces to DHCP, but I want the name server to be gotten from only one of them. The problem is, whoever gets the DHCP offer last, overrides the /etc/resolv.conf file to the wrong nameserver! I've deleted network-manager and network-manager-gnome as they are able to work with one interface a time.
Both interfaces are set to DHCP and 'auto' in /etc/networking/interfaces like this:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

auto eth1
allow-hotplug eth1
iface eth1 inet dhcp

I want the nameserver to be gotten always from eth1, how can I do that?

thanks!

Best Answer

I am not a big debian master, so I can't tell you how to do it in their rc scripts. However, if you are running dhclient it's not hard to do in the configuration. You define in dhclient.conf which options you want to retrieve from the server:

(The example from the man page)

interface "ep0" {
    send host-name "andare.fugue.com";
    send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
    send dhcp-lease-time 3600;
    supersede domain-name "fugue.com rc.vix.com home.vix.com";
    prepend domain-name-servers 127.0.0.1;
    request subnet-mask, broadcast-address, time-offset, routers,
            domain-name, domain-name-servers, host-name;
    require subnet-mask, domain-name-servers;
    script "/etc/dhclient-script";
    media "media 10baseT/UTP", "media 10base2/BNC";
}