Configuring DNS NameServer on Linux Cloud Servers

2020-02-05 By Sam 21126 Views linux dns nameserver networking
7 reviews

DNS name servers are used for name resolution from a server in all operating systems. In most Linux Operating systems, these DNS servers are specified in the file /etc/resolv.conf. This file contains one nameserver line which defines the DNS server.


This file can be viewed and the DNS nameservers edited by using the steps given below:


  1. Open the file using any editor.

    # vi /etc/resolv.conf
    

    dnsnameserver1

  2. Add lines for the name servers that need to be used.

    dnsnameserver2

    Here the common Google nameservers 8.8.8.8 and 8.8.4.4 have been used.


In modern Linux, this file is indirectly managed by the systemd-resolved service, and in some cases by the network service (by using initscripts or NetworkManager). Hence, manually changed values do not last or will get revoked after a reboot. To resolve this, the resolvconf utility can be installed and used to make the changes permanent. The below steps can be used for this.


  1. Run update before proceeding with the installation.

    # apt-get update
    

    dnsnameserver3

  2. Install resolvconf by executing the below command.

    # apt install resolvconf
    

    dnsnameserver4

  3. Verify the service status.

    # systemctl status resolvconf.service
    

    dnsnameserver5

    If the service is not started, it can be started using the below commands:

    # systemctl start resolvconf.service
    
    # systemctl enable resolvconf.service
    
    # systemctl status resolvconf.service
    

    dnsnameserver6

  4. Set up permanent DNS nameservers.

    # vi /etc/resolvconf/resolv.conf.d/head
    

    dnsnameserver7

    dnsnameserver8

    Here the common Google nameservers 8.8.8.8 and 8.8.4.4 have been used.

  5. Restart the service.

    # systemctl restart resolvconf.service
    

    dnsnameserver9


Related Tutorials

What do you think about this article?

Rate this article
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.