Step-by-step guide on how to change DNS settings on Ubuntu 22.04 or 24.04 (IPv4/IPv6) to use Google DNS or Cloudflare DNS for improved internet network performance and privacy.
List of High-Speed and Secure DNS Servers to Use
Supplier | IPv4 | IPv6 |
---|---|---|
Yandex DNS | 77.88.8.8 77.88.8.1 | 2a02:6b8::feed:0ff 2a02:6b8:0:1::feed:0ff |
Google DNS | 8.8.8.8 8.8.4.4 | 2001:4860:4860::8888 2001:4860:4860::8844 |
Cloudflare DNS | 1.1.1.1 1.0.0.1 | 2606:4700:4700::1111 2606:4700:4700::1001 |
Open DNS | 208.67.220.220 208.67.222.222 | 2620:119:35::35 2620:119:53::53 |
CleanBrowsing DNS | 185.228.168.9 185.228.169.9 | 2a0d:2a00:1::2 2a0d:2a00:2::2 |
Comodo Secure DNS | 8.26.56.26 8.20.247.20 | 0:0:0:0:0:FFFF:081A:381A 0:0:0:0:0:FFFF:0814:F714 |
DNS.Watch | 84.200.69.80 84.200.70.40 | 2001:1608:10:25::1c04:b12f 2001:1608:10:25::9249:d69b |
VeriSign Public DNS | 64.6.64.6 64.6.65.6 | 2620:74:1b::1:1 2620:74:1c::2:2 |
Quad9 DNS | 9.9.9.9 149.112.112.112 | 2620:fe::fe 2620:fe::9 |
AdGuard DNS | 94.140.14.14 94.140.15.15 | 2a10:50c0::ad1:ff 2a10:50c0::ad2:ff |
Method 1: Use the interface (GUI) to change DNS configuration
The first method is how to change DNS on Ubuntu using the graphical interface available in Settings. This method is simple and straightforward.
Step 1: Click on the network icon located in the top right corner of the screen, or open “Settings” and select “Network”.
Step 2: Click on the gear-shaped settings icon and configure change DNS on Ubuntu 22.04 as shown in the screenshot below.
Switch to the IPv6 Tab and change the DNS settings similar to the IPv4 configuration.
Click “Apply” to save the DNS changes.
Finally, turn off/on the internet or restart the internet connection using the command, then check if the DNS configuration appears as shown in the image below. If so, you have successfully changed the DNS on your Ubuntu 22.04 operating system.
sudo service NetworkManager restart
Note: You can use multiple DNS servers, for example, include Google DNS or Cloudflare DNS, as shown in the screenshot above.
Method 2: Use terminal command to configure DNS on Ubuntu 22.04
Ubuntu has a built-in Netplan tool that uses a YAML configuration file. We can use this tool to configure our DNS settings. Now, press “Ctrl + ALT + T” to open Terminal and navigate to the “netplan” folder.
cd /etc/netplan/
Then run the command to display the list of network configuration files in this directory:
ls
Based on the screenshot above, the configuration file for network manager is named “01-network-manager-all.yaml.” Now, I will proceed to run the command to open and modify the DNS configure DNS on Ubuntu 22.04 as follows:
sudo nano 01-network-manager-all.yaml
In this tutorial, I will create a new configuration with Google DNS that supports both IPv4 and IPv6. Copy the code below and paste it into the file named “01-network-manager-all.yaml”.
# Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager ethernets: eno1: # Change "eno1" to your network interface name. dhcp4: yes dhcp6: yes nameservers: addresses: [8.8.8.8, 8.8.4.4] search: [google.com] addresses: - "2001:4860:4860::8888/64" - "2001:4860:4860::8844/64"
Note the line “eno1:” and replace it with the name of your network interface. To check the network interface name, you can run the command ip a
, nmcli device status
, or netstat -i
.
netstat -i
After completing the configurations, save the file and apply the DNS changes on Ubuntu 22.04 using the following command:
sudo netplan apply sudo service NetworkManager restart
These DNS changes on Ubuntu help you access the internet more stable, secure, and especially allow access to websites blocked by your ISP. If you encounter any issues while configuring DNS on Ubuntu 22.04 or 24.04, simply remove the DNS configurations you have set and restart “Network Manager.”