Jan 2, 2024 5 min read

How to Set DNS Nameserver on Ubuntu 20.04

Set DNS Nameserver on Ubuntu 20.04 with our step-by-step tutorial. It is a fundamental component of the internet infrastructure.

Configure DNS Nameserver on Ubuntu 20.04
Set DNS Nameserver on Ubuntu 20.04
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to set DNS Nameserver on Ubuntu 20.04, let’s briefly understand – What is DNS Nameserver?

A DNS nameserver is a fundamental component of the internet infrastructure. It functions as a phonebook, translating domain names (like example.com) into corresponding IP addresses (like 192.0.2.1).

Nameservers contain databases of these mappings, allowing users to access websites using human-readable names. They act as intermediaries, facilitating communication between devices by managing the resolution process. Reliable and efficient nameservers are crucial for smooth internet browsing, ensuring seamless connectivity worldwide.

In this tutorial, you will configure DNS Nameserver in an independent environment on Ubuntu 20.04. We will also address a few FAQs on how to configure DNS Nmaeserver on Ubuntu 20.04.

Advantages of DNS Nameserver

  1. Efficient Resolution: DNS nameservers enable quick domain name resolution, ensuring that websites load fast and users have a smooth browsing experience.
  2. Redundancy: Multiple nameservers distribute the load, increasing reliability and minimizing downtime.
  3. Distributed Architecture: Nameservers worldwide enhance accessibility, optimizing global internet connectivity.
  4. Caching: Nameservers store previously resolved queries, reducing the need for repeated resolutions and improving overall performance.
  5. Scalability: Nameservers are easily scalable, accommodating growing internet traffic demands and expanding network infrastructure.

Prerequisites

  • Ubuntu 20.04 (both ways also work on Ubuntu 18.04 and above)
  • Access to the terminal
  • Sudo privileges

Change DNS Nameserver via GUI

To change DNS addresses using the graphical user interface, follow the instructions in Ubuntu Settings.

1) Open Settings and select the Network tab from the left-hand menu.

2) To configure a connection, turn the cogwheel adjacent to it.

Network
💡
Note: Choose the Wi-Fi tab, choose a wireless network, and then follow the below instructions to modify the settings for a wireless connection.

3) Navigate the IPv4 tab.

4) Disable the DNS field's automatic configuration by flipping the switch next to it.

5) In the field, type new DNS addresses. In the example, Google's public DNS nameservers are displayed.

6) Select "Apply."

DNS

Now that the new DNS servers are in place, the system is set up to use them.

💡
Note: Go to the IPv6 tab and enter your IPv6 nameservers there if you want to do so. IPv6 uses a different format for addresses than IPv4. The IPv6 DNS servers for Google, for instance, are 2001:4860:4860::8888 and 2001:4860:4860::8844.

Change DNS Nameserver via Config File

Change DNS settings using the command line Netplan tool if you don't use a GUI.

1) Visit the Netplan directory first:

cd /etc/netplan

2) To find the name of the yaml file containing network configuration, use ls to list the directory's contents.

terminal

Use a text editor to see the file. Your file's name could be different.

sudo nano 01-network-manager.yaml

The file's ethernets section contains a list of Ethernet connections. The wifis area is where you'll locate any wireless connections if there are any. Under each section's nameservers subsection, Netplan keeps track of the current DNS setup settings.

DNS Setup

The DNS addresses you intend to use should be substituted for the addresses found in the file. More than two addresses may be entered. Save your changes, then leave.

The full ethernets or wifis section may not be present in the file on your system. If so, fill in the gaps with the appropriate lines while adhering to the example's specified indentation.

3) Implement the config file alterations you made:

sudo netplan apply

There is no output in a successful operation. Type the following to see if the changes were made successfully by the system:

resolvectl status | grep "DNS Server" -A2

Your current DNS servers are listed in the output:

Current DNS

Why Change DNS Nameserver on Ubuntu?

The majority of the time, your DNS settings provide the best performance. Nonetheless, there are some circumstances in which you ought to think about switching to a different DNS provider:

  • Typically, larger businesses with greater infrastructure are better equipped to deliver consistent DNS service. If your ISP is inconsistent, and you frequently experience outages, changing your DNS provider can be the answer.
  • The DNS servers provided by a third party may be quicker than those offered by your ISP.
💡
Note: A fast third-party server that is far away may offer less reliable service than a slower one that is closer to you because latency is the main factor for DNS.
  • A few DNS service providers provide filters to stop phishing websites from accessing your computer. The similar mechanism is employed to filter sensitive internet content as well. This DNS feature is frequently used by businesses.
  • You might be able to access some geo-restricted websites by changing your DNS nameserver because Internet service providers occasionally block content at the DNS level.
💡
Note: See how to set up PowerDNS, a dependable and adaptable DNS solution, on Ubuntu.

FAQs to Configure DNS Nameserver on Ubuntu 20.04

Can I add multiple DNS nameservers?

Yes, you can add multiple DNS nameservers in the netplan configuration file by specifying each nameserver IP address.

How can I set up a DNS nameserver locally on Ubuntu 20.04?

Install a DNS server software like BIND or dnsmasq, configure it to listen on the desired network interface, and set the server IP as the nameserver in the netplan configuration file.

Can I use my ISP's DNS nameserver on Ubuntu 20.04?

Yes, you can use your Internet Service Provider's (ISP) DNS nameservers by specifying their IP addresses in the netplan configuration file.

What if my DNS nameserver is not responding?

If your DNS nameserver is unresponsive, consider using alternative public DNS servers like Google DNS (8.8.8.8) or Cloudflare DNS (1.1.1.1) temporarily.

How do I prioritize the order of DNS nameservers?

Place the most preferred DNS nameserver at the top of the list in the netplan configuration file. Ubuntu will try them sequentially until a successful DNS resolution is obtained.

Can I configure DNS nameservers through the Ubuntu graphical interface?

Yes, you can configure DNS nameservers using the "Network" section under the Ubuntu Settings graphical interface.

Are there any other ways to configure DNS nameservers on Ubuntu 20.04?

Yes, apart from netplan, you can also configure DNS nameservers by modifying the "resolv.conf" file directly or by using the NetworkManager configuration files. However, netplan is the recommended method for Ubuntu 20.04.

Conclusion

You now know how to set your DNS nameservers on Ubuntu, either using a GUI or CLI. If you have any suggestions or queries, kindly leave them in the comments section.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.