Configuring DNS NameServer on Linux Cloud Servers

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

 

Was this answer helpful? 0 Users Found This Useful

Related Articles

Complete List of Common Linux Server Commands

Mastering common Linux commands is the foundation of server management. File and Directory...

Detailed Tutorial on Linux Server Firewall Configuration

Firewall is the first line of defense for server security, and proper configuration is essential....

Steps and methods for handling zombie processes on Linux cloud servers

In daily use of Linux cloud servers, many website owners will encounter processes with a state of...

What to do if the cloud server port is occupied due to Nginx configuration error?

In the process of deploying or modifying Nginx configuration, many users often overlook a key...

Setting up Two-Factor Authentication for Linux Server

Why Use 2FA on a Linux Server? Despite their strong security, SSH keys are not infallible,...