The Domain Name System (DNS) translates text-based domain names into numeric IP addresses. By default, most networks are configured to work with DNS servers provided by your Internet service provider. However, users are free to change DNS name servers.
This tutorial will show you how to change DNS name servers on your Ubuntu machine using GUI or command line.
- 20.04 (both methods also work on Ubuntu 18.04 and later)
- Terminal access
- Sudo privileges Change
DNS name server via GUI
Use Ubuntu setup to complete all steps to change DNS addresses through the graphical user interface
1. Launch Settings and click the Network tab in the left menu
2. Click the gear next to the connection you want to configure.
3. Go to the IPv4 tab.
4. Disable DNS automatic configuration by turning off the switch next to the DNS field.
5. Enter new DNS addresses in the field. The example shows Google’s public DNS name servers.
6. Click Apply.
The system is now configured to work with the new DNS servers.
Change the DNS
name server through
the configuration file
If you do not use a GUI, change the DNS settings by using the Netplan command-line tool
1. Go to the Netplan directory:
2. List the contents of the directory with ls to see the name of the yaml file that contains the network settings.
Open the file in a text editor. The file may have a different name.
sudo nano 01-network-manager.yaml
Ethernet connections are listed in the Ethernet section of the file. If there are wireless connections, you can find them in the wifis section. Netplan stores the current DNS configuration parameters in name server subsections of each section.
Replace the addresses
located in the file with the DNS addresses that you want to use. You can enter more than two addresses. Save the changes and exit.
3. Apply the changes made to the configuration file:
sudo netplan apply
If the operation is successful, there is no output. To verify that the system applied the changes correctly, type:
resolvectl status | grep “DNS Server” -A2
The output lists your current
Why change DNS name server in Ubuntu?
In most cases, the default DNS settings provide optimal performance. However, there are scenarios where you should consider switching to a
third-party DNS provider –
- large companies with better infrastructure are typically better able to provide uninterrupted DNS service. If your ISP is unreliable and you experience frequent downtime, changing your DNS provider may be the solution.
- Third-party DNS servers may be faster than those provided by your ISP.
- 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. Companies often employ this DNS feature.
- Internet service providers sometimes block content at the DNS level, so switching to another DNS name server can help you access some geo-restricted websites.
This tutorial showed you how to set up your DNS name servers in Ubuntu, either using a GUI or CLI.
To learn more about DNS, read What is a domain name system and how does it work?