Ubuntu Add DNS Server: A Complete Guide


Greetings, fellow Ubuntu users! Today, we’re going to talk about one of the most essential aspects of networking on Ubuntu – adding a DNS server. DNS (Domain Name System) is what translates human-friendly domain names into IP addresses that computers can understand. Ubuntu allows you to add DNS servers to ensure faster and smoother web browsing experience. In this article, we’ll guide you through the process of adding DNS servers on Ubuntu in detail. So, let’s get started!

What is DNS?

DNS stands for Domain Name System, which is essentially the phonebook of the internet. Every website or web application is identified by a unique IP address. However, remembering the IP addresses of every website we visit can be quite challenging and inconvenient. That’s where DNS comes in. DNS is responsible for translating human-friendly domain names like www.google.com into IP addresses like that computers can understand.

Why add a custom DNS server on Ubuntu?

By default, Ubuntu uses the DNS server provided by your Internet Service Provider (ISP). These servers may not be the fastest or most reliable, and they may even be subject to censorship or surveillance. By adding a custom DNS server, you can experience faster and more secure web browsing, access to region-restricted content, and enhanced privacy.


Before we dive into the process of adding DNS servers on Ubuntu, please ensure that you have:

Ubuntu PC or Server Access to the internet Administrator privileges (sudo) The IP address of the DNS server(s) you want to use

Step-by-Step Guide: Adding DNS server on Ubuntu

Follow these steps to add DNS servers on Ubuntu:

Step 1: Backup your System

Before making any changes to your system configuration, it’s crucial to have a backup in case something goes wrong. You can use the built-in backup tool in Ubuntu or any other backup software you prefer.

Step 2: Open the Network Settings

Open the network settings on your Ubuntu system. You can do this by clicking on the network icon in the top-right corner of the screen and selecting “Settings.” Alternatively, you can open the terminal and type:

sudo nano /etc/netplan/01-netcfg.yaml

Step 3: Edit Network Configuration

Next, you need to edit your network configuration file. Find the line with “nameservers:” and add the IP addresses of the DNS servers you want to use, separated by a space. For example:

nameservers: [,]

You can use any DNS server you prefer, but Google Public DNS ( and is one of the most popular options.

Step 4: Apply Configuration Changes

Save and close the network configuration file. In the terminal, type:

sudo netplan apply

This will apply the changes you made to the network configuration.

Step 5: Test Your DNS Configuration

To test if your new DNS configuration is working, you can use the “dig” command. In the terminal, type:

dig www.google.com

This will return the IP address of the website you specified, along with other DNS information. If the IP address matches the one you expected, your DNS server configuration is working correctly.

Advantages of Adding Custom DNS Servers on Ubuntu

1. Faster Browsing

Custom DNS servers can help improve your web browsing speed and overall internet experience by reducing the time it takes to translate domain names into IP addresses. This is especially true if your ISP’s DNS servers are slow or overloaded.

2. Access Region-Restricted Content

Some websites and online services are only available in specific countries or regions. By using a custom DNS server, you may be able to bypass these restrictions and access content that would otherwise be unavailable.

READ ALSO  Setting Up an Ubuntu FTP Server: A Complete Guide

3. Enhanced Privacy

Your ISP’s DNS server may log your browsing history, which can compromise your privacy. By using a custom DNS server, you can ensure that your browsing activity is not being tracked by your ISP.

Disadvantages of Adding Custom DNS Servers on Ubuntu

1. Security Risks

If you’re not careful, using custom DNS servers can expose you to security risks. Malicious DNS servers can redirect your web traffic to fake websites, steal your login information, or inject malware into your system. To avoid these risks, make sure to use reputable DNS servers from trusted sources.

2. Compatibility Issues

Adding custom DNS servers may cause compatibility issues with certain applications or services that rely on your ISP’s DNS servers. If you experience any issues after adding custom DNS servers, you may need to switch back to your ISP’s DNS servers.

3. Limited Support

Custom DNS servers may not be officially supported by your ISP or device manufacturer. This means that you may not receive technical support if you encounter any issues with your custom DNS setup.


Q1: How do I find the IP address of my DNS server?

A: You can find the IP address of your DNS server by checking your router settings or contacting your Internet Service Provider.

Q2: Do I need to restart my system after adding custom DNS servers?

A: No, you don’t need to restart your system. You only need to apply the configuration changes using the “sudo netplan apply” command.

Q3: Can I use more than one DNS server?

A: Yes, you can use multiple DNS servers. Simply add their IP addresses to the “nameservers:” line in your network configuration file, separated by a space.

Q4: Can I revert to my ISP’s DNS servers?

A: Yes, you can revert to your ISP’s DNS servers by removing the custom DNS server IP addresses from your network configuration file.

Q5: Can I use custom DNS servers on a mobile device?

A: Yes, you can use custom DNS servers on Android and iOS devices. The process may vary slightly depending on your device and operating system version.

Q6: Are custom DNS servers safe?

A: Custom DNS servers can be safe if you use reputable DNS servers from trusted sources. Always make sure to do your research and use DNS servers that have a good reputation.

Q7: Can custom DNS servers prevent malware infections?

A: Custom DNS servers can help prevent malware infections by blocking access to known malicious websites. However, they are not a substitute for antivirus software or other security measures.


Adding custom DNS servers on Ubuntu is a simple but powerful way to improve your web browsing experience, access region-restricted content, and enhance your online privacy. By following the step-by-step guide in this article, you can easily add custom DNS servers to your Ubuntu system. However, it’s essential to be aware of the advantages and disadvantages of using custom DNS servers, as well as the potential security risks. We hope this article has been helpful in guiding you through the process of adding custom DNS servers on Ubuntu.


Adding custom DNS servers on Ubuntu can have many benefits, but it’s essential to use reputable DNS servers from trusted sources to avoid security risks. Always do your research and take appropriate precautions to ensure the safety and privacy of your online activities. We hope this article has provided you with valuable information and insights into the world of DNS servers on Ubuntu. Happy browsing!

READ ALSO  Ubuntu Server Restart: Everything You Need to Know

Video:Ubuntu Add DNS Server: A Complete Guide