Howto setup nameserver on Ubuntu 14.04 by resolvconf

    The purpose of this document is to guide you setup nameserver by resolvconf.

    resolvconf is a set of script and hooks managing DNS resolution. The most notable difference for the user is that any change manually done to /etc/resolv.conf will be lost as it gets overwritten next time something triggers resolvconf.

    Instead, The resolvconf uses DHCP client hooks, a Network Manager Plugin and /etc/network/interfaces to generate a list of nameservers and domain to put in /etc/resolv.conf

    About the directory: /etc/resolvconf/resolv.conf.d

    The directory may contain “base”, “head”, “original” and “tail” files. All in resolv.conf format. default is only base and head.

    • base: Used when no other data can be found
    • head: Used for the header of resolv.conf, can be used to ensure a DNS server is always the first one in the list
    • original: Just a backup of your resolv.conf at the time of resolvconf installation
    • tail: Any entry in tail is appended at the end of the resulting resolv.conf.

    Resolvconf Usage

    Append nameserver entries to resolv.conf after nameserver 127.0.1.1

    #sudo vim /etc/resolvconf/resolv.conf.d/tail
    

    Add the open DNS to this file:

    nameserver 208.67.222.222
    nameserver 208.67.220.220
    

    Then, update and check the /etc/resolv.conf

    $ sudo resolvconf -u
    $ cat /etc/resolv.conf 
    

    The open DNS nameserver has been appended after “nameserver 127.0.1.1”

    # 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
    nameserver 127.0.1.1
        nameserver 208.67.222.222
        nameserver 208.67.220.220
    

    Append nameserver entries to resolv.conf before nameserver 127.0.1.1

    $sudo vim /etc/resolvconf/resolv.conf.d/head
    

    Add the open DNS to the end of this file:

        nameserver 208.67.222.222
        nameserver 208.67.220.220
    

    Then, update and check the /etc/resolv.conf

    $ sudo resolvconf -u
        $ cat /etc/resolv.conf
    

    The open DNS nameserver has been appended before “nameserver 127.0.1.1”

        # 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
        nameserver 208.67.222.222
        nameserver 208.67.220.220
    nameserver 127.0.1.1
    

    Note

    If you want to setup a static IP address on Ubuntu, please refer to Howto setup static ip address on ubuntu 14.04. However, this change will result in NetworkManager is not working properly, even related VPN connection.

    Related articles

    comments powered by Disqus