Debian interfaces file - ignore gateway and dns entries from dhcp
In gentoo, this is as simple as:
dhcp_ethX="nodns nogateway"
How should I go about this in the interfaces file?
Solution 1:
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
Solution 2:
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.