Debian – set the Debian box to use OpenDNS nameservers if it uses DHCP

debiandhcpdnsnetworking

I have a Debian box with this in /etc/network/interfaces:

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
    wpa-ssid NetworkName
    wpa-psk NetworkPass

and this in /etc/resolv.conf (presumably this stuff gets pulled from my Cisco router automatically?)

domain cable.myisp.com
search cable.myisp.com
nameserver isp_nameserver_ip1
nameserver isp_nameserver_ip2

I'd like to use OpenDNS (or Norton Secure DNS, basically just some other DNS server), so can I just remove the first two lines from /etc/resolv.conf and update the last two with new nameserver IP addresses? Is there anything else I'd need to do?

I can change the settings on my router easy enough but is it possible to do this within the OS?

Best Answer

This site suggests you can put

option domain-name-servers x.y.z.1 x.y.z.2

into dhclient.conf. This will prevent dhclient from clobbering resolve.conf with your dhcp provided nameservers.

Personally I take the route you mention and tell my dhcp server on the router to provide the nameservers I want that way all of my machines get the benefit and not just one server.

Related Question