dhclient configures /etc/resolv.conf with invalid entry
Solution 1
Well the best approach would be to fix the dhcp server on your router, so it provides you with the correct setting...
If your cannot or do not want to do that you can adjust the dhclient configuration so it does not request dns servers via DHCP.
The configuration file for most distributions will probably be /etc/dhcp/dhclient.conf
. In this file you'll find a line similar to this:
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers,
dhcp6.domain-search, dhcp6.fqdn,
dhcp6.name-servers, dhcp6.sntp-servers;
Remove domain-name-server (and maybe domain-search) from this list and restart your dhclient process....
Solution 2
user "rbtux" is right. But there're special (commented) row in /etc/dhcp/dhclient.conf
before suggested:
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers,
dhcp6.domain-search, dhcp6.fqdn,
dhcp6.name-servers, dhcp6.sntp-servers;
I have uncommented it & it work for me.
sry for my Eng.
Related videos on Youtube
kubal5003
Software developer specializing in web technologies
Updated on September 18, 2022Comments
-
kubal5003 almost 2 years
I'm trying to figure out why running dhclient on my interface sets /etc/resolv conf to the ip number of my gateway(router).
This entry is invalid and each and every time causes inability to resolve any address.
I would like to:
- stop dhclient from overwriting the /etc/resolv.conf or
- make dhclient write there the valid dns ip from my router
More on the environment: I'm using virtual Debian Wheezy as a client system on Windows Seven x64. It is run by Virtualbox with networking mode set to bridged (all packets from debian are injected to my network interface on windows).
If I manually configure the /etc/resolv.conf then everything works fine. Doing this on every boot is quite annoying..
PS> I know I can write a script to do it for me, but this is not the solution I want. //edit
- router ip:
192.168.1.100
- /etc/resolv.conf AFTER running dhclient eth0: "
nameserver 192.168.1.100
" - what I would like the /etc/resolv.conf to look like: "
nameserver 89.202.xxxx
" (I don't have to provide the real ip do I? )
All other devices - laptop with Ubuntu, two phones with Android, laptop with Windows 7 are able to obtain correct DNS entries from the route
-
kubal5003 over 11 yearsWhy do you think this is what really happens? I have many devices connected to this router and ONLY debian has issues with it. All other devices - laptop with Ubuntu, two phones with Android, laptop with Windows 7 are able to obtain correct DNS entries from the router!
-
kubal5003 over 11 yearsI would like to know why this is happening. Today I'll try to do tcpdump and find out what my router sends. Static dns entry in my config is not what I want in the end..
-
kubal5003 over 11 yearsI haven't done this. I'm going to do that today. I don't expect
dhclient.conf
to contain anything special since no one has ever altered it and this ip number is quite unique. -
kubal5003 over 11 yearsI found out that my router is causing the problem - it sends its own ip as dns server. I'm thinking now that this configuration might be ok if all other devices are running good and the problem lies somewhere else..
-
kubal5003 over 11 yearsI'd rather create a new question, because this one is completely valid and the answer is also valid.
-
Paul over 11 yearsYeah, I agree. The question could do with some tightening to remove the parts that turned out to be incorrect, but yes, it is a useful addition to the site.
-
kubal5003 over 11 yearsThanks! That's definitely a good way to cope with this issue. Nevertheless I'm still wondering why this is set to the wrong value..
-
andrekeller over 11 yearsthats a valid option if you run a local dns resolver (such as dnsmasq)
-
Artsiomius over 11 yearsagree. I use bind9.
-
Artsiomius over 11 yearsbut you can change
prepend domain-name-servers 127.0.0.1
toprepend domain-name-servers xxx.xxx.xxx.xxx
-
andrekeller over 11 yearsyes of course... there are several possibilities...