-->

DEVOPSZONES

  • Recent blogs

    How to Set permanent DNS nameservers on Ubuntu with resolv.conf

    How to Set permanent DNS nameservers on Ubuntu with resolv.conf 

    With the default resolv.conf file in ubuntu the nameserver is mentioned as following  "nameserver 127.0.0.53".

    Resolv.conf file Ubuntu
    Resolv.conf file Ubuntu


    The Original DNS servers behind this can be found with "resolvectl status" command.

    How to Set permanent DNS nameservers on Ubuntu with resolv.conf
    resolvectl status

    The problem with that , you fill face "Temporary name resolution failures" errors frequently. To Solve that we'll need to do the foloowing steps.


    Solution:

    Installing resolvconf package

    Let’s install the resolvconf package. Enter the following code:

    sudo apt update
    sudo apt install resolvconf

    To enable and start the resolvconf service, enter the following code:

    sudo systemctl enable resolvconf.service
    sudo systemctl start resolvconf.service
    sudo systemctl status resolvconf.service

    Resolvconf service status

    Resolvconf service status

    Set DNS servers in resolv.conf using head file

    Now we get to the meat of this article. Let’s open the head file:

    sudo nano /etc/resolvconf/resolv.conf.d/head

    Enter your nameservers below the comments (I’m using Google’s DNS servers).

    nameserver 192.168.0.1
    nameserver 8.8.8.8

    We need to update resolv.conf to use the new nameservers. Enter the following code:

    sudo resolvconf --enable-updates
    sudo resolvconf -u
    root@k8s-master:~# 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
    # 127.0.0.53 is the systemd-resolved stub resolver.
    # run "systemd-resolve --status" to see details about the actual nameservers.
    nameserver 192.168.0.1
    nameserver 8.8.8.8
    nameserver 127.0.0.53
    options edns0 trust-ad
    root@k8s-master:~#

    No comments