DNS (Domain Name System) Nameservers are servers that store record of domain names and their IP addresses. DNS Servers can contain different types of records such as A, AAAA, NS and mail exchanger records. They help browsers and internet service providers (ISPs) perform DNS lookups for domain names and respond with their corresponding addresses. Almost every ISP is configured to a DNS server to speed up web browsing. In this article, we will learn how to configure DNS Nameserver in Ubuntu. Please note, although every ISP comes with a default DNS Nameserver, you are free to change them as per your requirements.
Please note, this solution is suitable for Ubuntu distributions that use GNOME NetworkManager.
How to Configure DNS Nameserver in Ubuntu
We will look at two ways to change DNS Nameservers – via GUI and via CLI.
1. Change DNS Nameserver via GUI
Here are the steps to change DNS nameserver address via GUI.
1. Launch Settings and click Network tab in the menu on the left.
2. Click the gear icon next to connection you wish to setup
3. Go to IPv4 tab.
4. Disable automatic DNS configuration by turning off switch next to DNS field.
5. Enter the new DNS server you want to connect to. We will be connecting to Google Nameserver. So enter its IP address as shown below.
6. Click Apply to apply changes.
2. Change DNS Nameserver via CLI
Here are the steps to change DNS Nameserver via CLI.
Open terminal and go to netplan folder
$ cd /etc/netplan
Run the ls command to list all files & folders.
$ ls
You will see a YAML file in the output. Open it in a text editor.
$ sudo vi 01-network-manager.yaml
Replace the addresses in red box below, with the IP addresses of DNS server you want to connect to. You can enter multiple IP addresses in a comma-separated manner.
Apply the changes with the following command.
$ sudo netplan apply
Run the following command to verify if the changes have been applied correctly.
$ systemd-resolve --status | grep 'DNS Servers' -A2
In this article, we have learnt how to configure DNS Nameserver in Ubuntu. People change their DNS Nameserver if their browsing speed is low or they experience frequent downtime. Many third-party DNS Nameservers like that of Google are fast, reliable and secure. Some DNS Nameservers also prevent access to phishing websites thereby protecting your system. So depending on your requirement, you can change your system’s DNS Nameserver.
Also read:
How to Configure LDAP Client for Ubuntu
How to Copy File to Clipboard in Ubuntu
How to Assign Command Output to Variable in Shell Script
How to Disable Package Updates in Yum/Dnf
How to group By Multiple Columns in Python Pandas
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.
It would be good if you explained that this solution as shown is only good for Ubuntu distributions that use GNOME NetworkManager.
Lotsa folks still don’t like NetworkManager even though it has nmcli now. I installed Ubuntu Server 22.04 LTS and it uses systemd-resolved not NetworkManager. So in your solution, the renderer would be networkd . My server never moves so I don’t need either one, a static /etc/resolv.conf file will work fine.
See this thread especially my solution (June 4)
https://ubuntuforums.org/showthread.php?t=2475025
Thank you for the feedback. We have updated the post accordingly.