Choose a different version or distribution
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
- Efficient Resolution: DNS nameservers enable quick domain name resolution, ensuring that websites load fast and users have a smooth browsing experience.
- Redundancy: Multiple nameservers distribute the load, increasing reliability and minimizing downtime.
- Distributed Architecture: Nameservers worldwide enhance accessibility, optimizing global internet connectivity.
- Caching: Nameservers store previously resolved queries, reducing the need for repeated resolutions and improving overall performance.
- Scalability: Nameservers are easily scalable, accommodating growing internet traffic demands and expanding network infrastructure.
- 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.
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."
Now that the new DNS servers are in place, the system is set up to use them.
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:
2) To find the name of the yaml file containing network configuration, use
ls to list the directory's contents.
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.
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.
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:
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.
- 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.
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 (22.214.171.124) or Cloudflare DNS (126.96.36.199) 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.
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.