How Do I Add a DNS Server to Resolv Conf?


Scott Campbell

Adding a DNS server to the resolv.conf file is an essential step in configuring the domain name system resolution on your machine. The resolv.conf file contains the necessary information for your system to resolve domain names to IP addresses.

Step 1: Open the resolv.conf File

To get started, open the resolv.conf file using a text editor of your choice. The location of this file may vary depending on your operating system. On most Linux distributions, you can find it at /etc/resolv.conf.

Step 2: Edit the resolv.conf File

Once you have the resolv.conf file open, you can add or modify the DNS servers listed inside it. Each DNS server entry should be on a new line and follow the format:

# The IP address of the DNS server
nameserver [IP address]

You can add multiple DNS servers by adding multiple nameserver entries.


# Primary DNS server
nameserver 8.8.8

# Secondary DNS server
nameserver 8.4.4

Step 3: Save and Close the File

After adding or modifying the DNS servers, save and close the resolv.conf file.

Step 4: Test DNS Resolution

To ensure that your changes have taken effect successfully, you can test DNS resolution using various methods like pinging a domain or performing a web request.

  • Ping a domain:
    Open your terminal or command prompt and run the following command:
  • Perform a web request:
    Open your web browser and visit a website to see if it loads correctly.

If both the ping and web request are successful, it means that your system is now using the added DNS servers for name resolution.


In this tutorial, you learned how to add a DNS server to the resolv. By configuring your DNS servers correctly, you ensure that your system can resolve domain names to their respective IP addresses, enabling smooth internet browsing and network communication.

Remember to save and close the resolv.conf file after making any changes. Additionally, always test DNS resolution to verify that your changes have taken effect successfully.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy