DNS is not working, /etc/resolv.conf is not overwritten. Why?

16,180

The dnsmasq executable binary is included in the dnsmasq-base package.

When dns=dnsmasq appears uncommented in NetworkManager.conf, NetworkManager runs a dnsmasq instance to serve as a local forwarding nameserver.

The dnsmasq package includes configuration files which support running a dnsmasq instance independently of NetworkManager. The latter dnsmasq instance is configured by /etc/dnsmasq.conf.

The resolvconf utility is used by network interface configurers to manage nameserver information. On the basis of information that it has been provided it writes a file /run/resolvconf/resolv.conf which is intended to be used to configure the libc resolver. The file is activated in this role by creating a symbolic link from /etc/resolv.conf to /run/resolvconf/resolv.conf.

NetworkManager and ifup send nameserver information to resolvconf. Normally /etc/resolv.conf is a symbolic link to /run/resolvconf/resolv.conf and all works well.

In case dns=dnsmasq appears uncommented in NetworkManager.conf, NetworkManager supplies resolvconf with the nameserver address 127.0.1.1 which appears in resolv.conf; NetworkManager's slave dnsmasq process listens at address 127.0.1.1 and forwards queries to external nameservers at addresses that NetworkManager has been configured to know about or has learned about via DHCP.

The questioner's first remark is:

But my file /etc/resolv.conf (symbolic link) is not overwritten by the Network Manager. 

This indicates that there is a misconfiguration. /etc/resolv.conf should be a symbolic link to /run/resolvconf/resolv.conf and resolvconf should update the latter when some network interface is configured or deconfigured. Given that you have dns=dnsmasq in NetworkManager.conf, the nameserver line in resolv.conf should be nameserver 127.0.1.1, unless you have the server instance of dnsmasq running in which case it might be nameserver 127.0.0.1, thus directing the libc resolver to use the server instance of dnsmasq which listens at 127.0.0.1.

The questioner's subsequent question is:

[...] /etc/resolvconf/resolv.conf.d/original [...]
Should I remove or edit this file to make it work?

This file (original) which is simply a copy of /etc/resolv.conf at the time the resolvconf package is installed, normally has no effect. It is kept by the resolvconf package in case the package is uninstalled, then this original file is put back at /etc/resolv.conf. In some cases /etc/resolvconf/resolv.conf.d/tail is a symbolic link to original but that is non-standard and if this holds for your system then you should change /etc/resolvconf/resolv.conf.d/tail to be an empty file or a symbolic link to /dev/null.

Share:
16,180

Related videos on Youtube

ChesuCR
Author by

ChesuCR

Currently working with Python, XML, Bootstrap, Odoo framework, PostgreSQL and more. I am a developer who enjoys learning and helping.

Updated on September 18, 2022

Comments

  • ChesuCR
    ChesuCR over 1 year

    I have this configuration in my server in the Network Manager connection:

    /etc/NetworkManager/system-connections/wired-connection

    [connection]
    id=wired-connection
    uuid=0c501f08acc5497cb7...
    type=8023ethernet
    
    [8023ethernet]
    
    [ipv4]
    method=manual
    dns=8.8.8.8;
    address1=192.168.1.250/24,192.168.1.1
    
    [ipv6]
    method=auto
    ip6privacy=0
    

    /etc/NetworkManager/NetworkManager.conf

    [main]
    plugins=ifupdown,keyfile,ofono
    dns=dnsmasq
    
    [ifupdown]
    managed=true
    

    But my file /etc/resolv.conf (symbolic link) is not overwritten by the Network Manager. If I add manually the line nameserver 8.8.8.8 to the file it works well, but it is only a temporal solution. If I open the IP configuration, in the interface of Kubuntu, I see the DNS fields empty.

    I also tried with this command, but it didn't work dpkg-reconfigure resolvconf

    The route of my original configuration file is in /run/resolvconf/resolv.conf

    And I found this file, it belongs to an old configuration /etc/resolvconf/resolv.conf.d/original

    nameserver 213.60.205.175
    nameserver 213.60.205.174
    nameserver 212.51.33.110
    

    Should I remove or edit this file to make it work?

    I can access only remotely to the server, due to this I would like to be sure that's going to work. If not I could break the connection

    Thanks in advance

    Update 03/08/15. Output of /usr/share/resolvconf/dump-debug-info

    ###### Start of debugging information for resolvconf ######
    ### ls -l /etc/resolvconf
    total 16
    -rw-r--r-- 1 root root  172 dic 13  2012 interface-order
    drwxr-xr-x 2 root root 4096 jul  8 18:33 resolv.conf.d
    drwxr-xr-x 2 root root 4096 jul  8 18:33 update.d
    drwxr-xr-x 2 root root 4096 jul  8 19:11 update-libc.d
    ### cat /etc/resolvconf/interface-order
    # interface-order(5)
    lo.inet*
    lo.dnsmasq
    lo.pdnsd
    lo.!(pdns|pdns-recursor)
    lo
    tun*
    tap*
    hso*
    em+([0-9])?(_+([0-9]))*
    p+([0-9])p+([0-9])?(_+([0-9]))*
    eth*
    ath*
    wlan*
    ppp*
    *
    ### ls -l /etc/resolvconf/resolv.conf.d
    total 8
    -rw-r--r-- 1 root root   0 dic 13  2012 base
    -rw-r--r-- 1 root root 151 dic 13  2012 head
    -rw-r--r-- 1 root root  77 jul  8 18:21 original
    -rw-r--r-- 1 root root   0 jul  8 18:26 tail
    ### cat /etc/resolvconf/resolv.conf.d/base
    ### cat /etc/resolvconf/resolv.conf.d/head
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    ### cat /etc/resolvconf/resolv.conf.d/original
    nameserver 213.60.205.175
    nameserver 213.60.205.174
    nameserver 212.51.33.110
    ### cat /etc/resolvconf/resolv.conf.d/tail
    ### ls -l /etc/resolvconf/run
    ls: no se puede acceder a /etc/resolvconf/run: No existe el archivo o el directorio
    ### ls -l /run/resolvconf
    total 4
    -rw-r--r-- 1 root root   0 jul 29 10:10 enable-updates
    drwxr-xr-x 2 root root  40 jul 29 10:10 interface
    -rw-r--r-- 1 root root 151 ago  3 09:40 resolv.conf
    ### cat /run/resolvconf/enable-updates
    ### cat /run/resolvconf/resolv.conf
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    ### ls -l /run/resolvconf/interface
    total 0
    ### ls -l /etc/resolv.conf
    lrwxrwxrwx 1 root root 29 jul 24 12:59 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
    ### lsattr /etc/resolv.conf
    lsattr: La operación no está soportada Mientras se leían las banderas en /etc/resolv.conf
    ### cat /etc/resolv.conf
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    ### cat /etc/NetworkManager/NetworkManager.conf
    [main]
    plugins=ifupdown,keyfile,ofono
    dns=dnsmasq
    
    [ifupdown]
    managed=true
    ###### End of debugging information for resolvconf ######
    

    I'm using Kubuntu 14.04 by the way

    • jdthood
      jdthood almost 9 years
      This: dns-search=8.8.4.4; looks wrong. The elements of the DNS search list should be domain names, not IP addresses.
    • jdthood
      jdthood almost 9 years
      Please run /usr/share/resolvconf/dump-debug-info in a terminal window and add the output to your question.
    • ChesuCR
      ChesuCR almost 9 years
      I didn't find /usr/share/resolvconf/dump-debug-info in my system
    • jdthood
      jdthood almost 9 years
      Make sure you have the resolvconf package installed.
    • ChesuCR
      ChesuCR almost 9 years
      Yes, it's installed: i resolvconf - name server information handler
    • ChesuCR
      ChesuCR almost 9 years
      @jdthood I found the script here. I'm going to update the question with the output
    • jdthood
      jdthood over 8 years
      Thanks. See my comment elsewhere about the debug output.
  • ChesuCR
    ChesuCR almost 9 years
    Thank you for your good explanation. In fact /etc/resolv.conf is a symbolic link to /run/resolvconf/resolv.conf, but it doesn't take any nameserver. And tail is simply a empty file. If I write manually nameserver 127.0.1.1 in the file /run/resolvconf/resolv.conf it doesn't work. It works only when I write nameserver 8.8.8.8. I also checked the file /etc/hosts and it has these two lines: 127.0.0.1 localhost and 127.0.1.1 my-pc-name. I still don't know what is wrong.
  • ChesuCR
    ChesuCR almost 9 years
    When I say my-pc-name I mean my hostname
  • jdthood
    jdthood almost 9 years
    I just looked at the output of dump-debug-info which you posted in your question. Everything looks normal, except that there are no resolvconf records, i.e., no files in /run/resolvconf/interface/. Normally NetworkManager submits to resolvconf a record named "NetworkManager" comprising either nameserver 127.0.1.1 plus the domain search path statement (if dns=dnsmasq in NetworkManager.conf) or nameserver EXTERNALNAMESERVERADDRESS plus the domain search path statement (otherwise). But for some reason this does not appear to have happened.
  • jdthood
    jdthood over 8 years
    You can also try removing and re-installing the resolvconf package. Please let us know the results of these experiments.
  • ChesuCR
    ChesuCR over 8 years
    Thank you @jdthood for your interest. I would like to experiment more in that server and find a permanent solution, but it is very risky because if something is not working as expected maybe I loose the communication with the server and that could be a big problem (the server is far away). Finally I just added manually nameserver 8.8.8.8 to the /etc/resolv.conf file as a temporary solution. If I find out something new or if I can make some tests I'll let you know :), and sorry for the late comment