How To Set Permanent DNS Nameservers in Ubuntu and Debian

How To Set Permanent DNS Nameservers in Ubuntu and Debian

How To Set Permanent DNS Nameservers in Ubuntu and Debian

The /etc/resolv.conf is the main configuration file for the DNS name resolver library. The resolver is a set of functions in the C library that provide access to the Internet Domain Name System (DNS). The functions are configured to check entries in the /etc/hosts file, or several DNS name servers, or to use the host’s database of Network Information Service (NIS).

On modern Linux systems that use systemd (system and service manager), the DNS or name resolution services are provided to local applications via the systemd-resolved service. By default, this service has four different modes for handling the Domain name resolution and uses the systemd DNS stub file (/run/systemd/resolve/stub-resolv.conf) in the default mode of operation.

The DNS stub file contains the local stub 127.0.0.53 as the only DNS server, and it is redirected to the /etc/resolv.conf file which was used to add the name servers used by the system.

If you run the following ls command on the /etc/resolv.conf, you will see that this file is a symlink to the /run/systemd/resolve/stub-resolv.conf file.

  1. "lrwxrwxrwx 1 root root 39 Feb 15 2019 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf"
  2. Unfortunately, because the /etc/resolv.conf is indirectly managed by the systemd-resolved service, and in some cases by the network service (by using initscripts or NetworkManager), any changes made manually by a user can not be saved permanently or only last for a while.

    In this article, we will show how to install and use the resolvconf program to set permanent DNS name servers in /etc/resolv.conf file under Debian and Ubuntu Linux distributions.

    Why Would You Want to Edit /etc/resolv.conf File?

    The main reason could be because the systems DNS settings are misconfigured or you prefer to use specific name servers or your own. The following cat command shows the default name server in the /etc/resolv.conf file on my Ubuntu system.

  3. $ cat /etc/resolv.conf


  4. In this case, when local applications such as the APT package manager try to access FQDNs (Fully Qualified Domain Names) on the local network, the result is a “Temporary failure in name resolution” error as shown in the next screenshot.



    The same happens when you run a ping command.

  5. $ ping google.com


  6. So when a user tries to manually set the name servers, the changes do not last for long or are revoked after a reboot. To resolve this, you can install and use the reolvconf utility to make the changes permanent.

    To install the resolvconf package as shown in the next section, you need to first of all manually set the following name servers in the /etc/resolv.conf file, so that you access the FQDMs of Ubuntu repository servers on the internet.

  7. nameserver 8.8.4.4
  8. nameserver 8.8.8.8
  9. Installing resolvconf in Ubuntu and Debian

    First, update the system software packages and then install resolvconf from the official repositories by running the following commands.

  10. $ sudo apt update
  11. $ sudo apt install resolvconf
  12. Once the resolvconf installation is complete, systemd will trigger the resolvconf.service to be automatically started and enabled. To check if it is up and running issues the following command.

  13. $ sudo systemctl status resolvconf.service
  14. If the service is not started and enabled automatically for any reason, you can start and enable it as follows.

  15. $ sudo systemctl start resolvconf.service
  16. $ sudo systemctl enable resolvconf.service
  17. $ sudo systemctl status resolvconf.service



  18. Set Permanent DNS Nameservers in Ubuntu and Debian

    Next, open the /etc/resolvconf/resolv.conf.d/head configuration file.

  19. $ sudo nano /etc/resolvconf/resolv.conf.d/head
  20. and add the following lines in it:

  21. nameserver 8.8.8.8
  22. nameserver 8.8.4.4


  23. Save the changes and restart the resolvconf.service or reboot the system.

  24. $ sudo systemctl start resolvconf.service
  25. Now when you check the /etc/resolv.conf file, the name server entries should be stored there permanently. Henceforth, you will not face any issues concerning name resolution on your system.



    I hope this quick article helped you in setting the permanent DNS nameservers in your Ubuntu and Debian systems. If you have any queries or suggestions, do share it with us in the comments section below.


    • Related Articles

    • Domains Forwarding & Redirections

      Foodhub Domains Point of Contact - New Business Company Policies on Foodhub Domains No Domains shall be returned or transferred back to clients under any circumstances New Domains purchases or Domain name changes will be charged £25 If the client has ...
    • A920 - Installation

      A920 - Terminal Overview Icon Overview Set up / Installation Installation will be done in 2 phases Device Configuration on PAX store Device Set up PAX Store Configuration ‌Device must be renamed (Takeaway Name & Store ID) launcher must be changed ...
    • Order notification Issue

      Follow the below mentioned steps to resolve the order notification issue. Device volume can be adjusted through volume option under App settings. If client requests for change in the notification tone, this can be updated from Notification tone. ...
    • Cashdraw configuration - Fusion React

      Perform the below checks to troubleshoot cashdraw issues. Check if the cash draw is from Foodhub as 3rd party cash draws are not compatible for now with Fusion react. If the cash draw is from Foodhub, check if the cash draw is connected to the ...
    • Internet & Wifi Network Troubleshooting on FULL EPOS & Android POS

      Network Issues on FULL EPOS Ensure Green & Amber lights on both the LAN ports where the ethernet is connected Ethernet cable must be connected only next to the VGA port under the EPOS Switch the Ethernet cable to a different port on the router & swap ...