x32x01
  • by x32x01 ||
The Domain Name System (DNS) translates text-based domain names to numeric IP addresses. By default, most networks are configured to work with DNS servers supplied by the internet service provider. However, users are free to change the DNS nameservers.

This tutorial will show you how to change DNS nameservers on your Ubuntu machine using GUI or the command line.
How to set DNS Nameserver on Ubuntu 20.04.jpg
Prerequisites
  • Ubuntu 20.04 (both methods also work on Ubuntu 18.04 and later)
  • Access to the terminal
  • Sudo privileges
Change DNS Nameserver via GUI
Use Ubuntu Settings to complete all the steps to change DNS addresses via the graphical user interface.
1. Launch Settings and click the Network tab in the menu on the left.
2. Click the cogwheel next to the connection you wish to set up.
opening-the-network-tab-in-ubuntu-20-04-settings.png
Note: To change the settings for a wireless connection, select the Wi-Fi tab, choose a wireless network and proceed with the steps below.

3. Go to the IPv4 tab.
4. Disable automatic DNS configuration by turning off the switch next to the DNS field.
5. Type new DNS addresses in the field. The example shows Google's public DNS nameservers.
6. Click Apply.
configuring-new-dns-settings-in-ubuntu-20-04.png
The system is now configured to work with the new DNS servers.

Note: If you wish to set up IPv6 nameservers, go to the IPv6 tab and enter them there. The IPv6 address format is different from IPv4. For example, Google’s IPv6 DNS servers are: 2001:4860:4860::8888 and 2001:4860:4860::8844.

Change DNS Nameserver via Config File
If you do not use a GUI, change DNS settings with the command line Netplan tool.
1. Go to the Netplan directory:
Code:
cd /etc/netplan

2. List the directory contents with ls to see the name of the yaml file containing network configuration.
output-from-ls-etc-netplan.png
Open the file in a text editor. Your file may have a different name.
Code:
sudo nano 01-network-manager.yaml

Ethernet connections are listed in the ethernets section of the file. If there are any wireless connections, you can find them in the wifis section. Netplan stores the current DNS configuration parameters in nameservers subsections of each section.
editing-netplan-yaml-file-in-nano.png
Replace the addresses located in the file with the DNS addresses you want to use. You can enter more than two addresses. Save the changes and exit.

Note: The file on your system may lack the entire ethernets or wifis section. In that case, add the lines that are missing, making sure you respect the indentation provided in the example.

3. Apply the changes you made in the config file:
Code:
sudo netplan apply

If the operation is successful, there is no output. To check if the system successfully applied the changes, type:
Code:
systemd-resolve --status | grep 'DNS Servers' -A2

The output lists your current DNS servers:
output-from-resolvectl-status-grep-dns-servers-a2-1.png
Why Change DNS Nameserver on Ubuntu?
In most cases, your default DNS settings offer optimal performance. However, there are scenarios in which you should consider switching to a third-party DNS provider:
  • Large companies with better infrastructure are usually more capable of providing uninterrupted DNS service. If your ISP is unreliable and you experience frequent downtimes, switching the DNS provider may be the solution.
  • Third-party DNS servers can be faster than those provided to you by your ISP.

Note: Since latency is the primary consideration for DNS, a fast third-party server located far away may provide inferior service to a slower one that is closer to you.
  • Some DNS providers offer filters that prevent phishing sites from reaching your computer. The same mechanism is also used to block sensitive content on the internet. Businesses often employ this DNS feature.
  • Internet Service Providers sometimes block content on the DNS level, so switching to another DNS nameserver may help you access some geo-restricted websites.
Conclusion
This tutorial showed you how to set your DNS nameservers on Ubuntu, either using a graphical user interface or the command line.
 

Similar Threads

x32x01
Replies
0
Views
234
x32x01
x32x01
x32x01
Replies
0
Views
238
x32x01
x32x01
x32x01
  • x32x01
Replies
0
Views
205
x32x01
x32x01
x32x01
  • x32x01
Replies
0
Views
213
x32x01
x32x01
x32x01
  • x32x01
Replies
0
Views
536
x32x01
x32x01
TAGs: Tags
dns nameserver

Register & Login Faster

Forgot your password?

Latest Resources

Forum Statistics

Threads
517
Messages
518
Members
45
Latest Member
Tacola
Back
Top