Debian never use router gateway address in resolv.conf

2

3

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 192.168.1.1) 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

 address 192.168.1.170
 netmask 255.255.255.0
 network 192.168.1.0
 broadcast 192.168.1.255
 getaway 192.168.1.1
 up route add -net default gw 192.168.1.1 netmask 0.0.0.0 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
nameserver 192.168.1.1

yaqo

Posted 2012-02-03T17:38:54.363

Reputation: 23

Answers

4

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.

Celada

Posted 2012-02-03T17:38:54.363

Reputation: 2 120

2

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

scotjam1981

Posted 2012-02-03T17:38:54.363

Reputation: 69

0

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.

Alnitak

Posted 2012-02-03T17:38:54.363

Reputation: 656