Super User is a question and answer site for computer enthusiasts and power users. 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

Debian never use router gateway address in resolv.conf

How could I setup Debian to (never use router as Domain Name resolver)does not display the router gateway address (nameserver in /etc/resolv.conf when I restart the computer or execute /sbin/dhclient?

I use only one line in /etc/dhcp/dhclient.conf

prepend domain-name-servers x.x.x.x,y.y.y.y,z.z.z.z;

This is my /etc/network/interfaces file:

 auto eth0 
 iface eth0 inet static

 up route add -net default gw netmask eth0

 dns-nameservers x.x.x.x y.y.y.y z.z.z.z

If I run /sbin/dhclient /etc/init.d/networking restart

my /etc/resolv.conf contains:

nameserver x.x.x.x
nameserver y.y.y.y
nameserver z.z.z.z
share|improve this question

migrated from Feb 3 '12 at 23:37

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

First of all, please clean up your configuration. Is your eth0 interface supposed to be configured with a static IP address or with DHCP? If static, why are you running dhclient? If DHCP, why does /etc/network/interfaces list static IP parameters and iface eth0 inet static instead of iface eth0 inet dhcp? Also, there is no reason you would need to add a default route via your up route command since you already specified the default route as the gateway parameter.

Now keep in mind that as per the name, prepend domain-name-servers adds DNS servers to the list that is supplied by the DHCP server. It doesn't replace them.

I recommend that, instead of asking dhclient to customize the name servers you want to use, use the resolvconf framework instead. resolvconf coordinates all of the different possible sources of DNS nameserver information (including separate DHCP clients running on one or more network interfaces, local DNS servers you want to use as resolvers, and static configuration) and centralized the building of a single coherent /etc/resolv.conf file. It's much better than letting several different things manage /etc/resolv.conf and have them stomp over each other trying to do it.

Install the resolvconf package if it isn't already installed. This will automatically disable dhclinent's direct mucking with the /etc/resolv.conf file.

Now your requirement is that you don't want to use the nameserver(s) provided by the DHCP server, so comment the line that reads eth* in /etc/resolvconf/interface-order. Be sure to also comment the last line of the file that reads *, otherwise eth0 will still be considered.

Next, you want to use a set of statically provisioned nameservers instead. Since they're system-global (not related to the state if any given interface), you can add them as nameservers on the lo interface in /etc/network/interfaces:

iface lo inet loopback
    dns-nameservers x.x.x.x y.y.y.y z.z.z.z

And then ifdown lo; ifup lo to activate this.

share|improve this answer

One other point: getaway should be gateway (which is probably why you have had to add the default route in order to get anything working?)

share|improve this answer

If you can possibly avoid it, don't use your gateway as a resolver at all.

They're notoriously buggy at doing DNS proxying - see RFC 5625.

You have a perfectly functional Linux box - just drop a copy of BIND or even better "Unbound" on it.

ObDisclaimer - I wrote that RFC.

share|improve this answer

You must log in to answer this question.

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