There are two common ways to change the DNS server on Ubuntu: the Settings app on the desktop edition, and a Netplan configuration file on the server edition. Either way, the change affects only that computer.
On Ubuntu, the /etc/resolv.conf file is usually managed by the system. If you edit it by hand, your change may be overwritten after a restart, so the methods below are recommended. If you are new to DNS, start with What is DNS?.
Changing DNS from the Settings app on the desktop
- Open the Settings app.
- Go to Network for a wired connection or Wi-Fi for a wireless one.
- Click the gear icon next to the network you are connected to.
- Open the IPv4 tab.
- In the DNS section, turn off the Automatic switch.
- Enter the DNS addresses separated by commas, for example:
1.1.1.1, 1.0.0.1 - Click Apply, then turn the network connection off and on again.
If you use IPv6, do the same on the IPv6 tab. Menu names may vary by Ubuntu version and desktop environment. You can find addresses to use in public DNS servers.
Changing DNS with Netplan on a server
On Ubuntu Server, network settings live in YAML files in the /etc/netplan/ folder. The file name differs from system to system. Back up the file before editing it.
network:
version: 2
ethernets:
eth0:
dhcp4: true
dhcp4-overrides:
use-dns: false
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
Replace eth0 with the name of your own network interface (you can see it with ip a). YAML files are indented with spaces; tab characters cause errors. After saving, apply it in trial mode first:
sudo netplan try
sudo netplan apply
If you are working on a remote server, a wrong Netplan setting can cut your connection. The netplan try command rolls the settings back after a short time unless you confirm them.
Checking the change and clearing the cache
To see which DNS server is in use:
resolvectl status
Look at the “DNS Servers” line under the relevant interface. To clear the DNS cache:
sudo resolvectl flush-caches
To see which address a domain resolves to, use resolvectl query example.com.
If the change does not work
- If “secure DNS” (DNS over HTTPS) is on in your browser, the browser does not use the system DNS. See encrypted DNS for details.
- If a VPN is on, DNS queries usually go through the VPN.
- For other causes, see I changed DNS but the site still will not open.
To change DNS for every device at home in one go, changing DNS on your router is more practical.

