dhclient configures /etc/resolv.conf with invalid entry

5,029

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.

Share:
5,029

Related videos on Youtube

kubal5003
Author by

kubal5003

Software developer specializing in web technologies

Updated on September 18, 2022

Comments

  • kubal5003
    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
      kubal5003 over 11 years
      Why 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
      kubal5003 over 11 years
      I 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
      kubal5003 over 11 years
      I 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
      kubal5003 over 11 years
      I 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
      kubal5003 over 11 years
      I'd rather create a new question, because this one is completely valid and the answer is also valid.
    • Paul
      Paul over 11 years
      Yeah, 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
    kubal5003 over 11 years
    Thanks! 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
    andrekeller over 11 years
    thats a valid option if you run a local dns resolver (such as dnsmasq)
  • Artsiomius
    Artsiomius over 11 years
    agree. I use bind9.
  • Artsiomius
    Artsiomius over 11 years
    but you can change prepend domain-name-servers 127.0.0.1 to prepend domain-name-servers xxx.xxx.xxx.xxx
  • andrekeller
    andrekeller over 11 years
    yes of course... there are several possibilities...