DNS (Domain Name System) is what translates domain names into IP addresses. When you type a website address into your browser, your operating system first checks its local hosts file for a matching entry. If it finds nothing, it queries the configured DNS nameservers to resolve the domain.
By default, DNS resolvers are assigned automatically by your ISP. These resolvers are often slow, poorly maintained, or in some cases used to log browsing activity. Switching to a faster, privacy-focused public DNS server can improve response times and reliability.
The most popular public DNS resolvers are:
Router tip: If you want every device on your local network to use the same DNS servers, make the change on your home router instead of configuring each device separately.
On Ubuntu 18.04 Desktop, you configure DNS through the Network Manager graphical interface. No terminal required.
Open Settings and click the Wi-Fi tab if you are on a wireless connection, or the Network tab for a wired connection.
Find your active connection and click the cog icon to open its settings. Go to the IPv4 tab.
Disable the Automatic toggle next to DNS. Enter your preferred DNS server addresses separated by a comma — for example, 8.8.8.8, 8.8.4.4 for Google DNS or 1.1.1.1, 1.0.0.1 for Cloudflare.
Click Apply to save the changes. The new DNS settings take effect immediately, though entries already cached by the system or an application may continue using the old resolver until the cache expires.
To revert to your ISP’s default DNS, open Network Manager, go back to the IPv4 tab, and re-enable the Automatic toggle. Your system will start using your ISP’s resolvers right away.
On Ubuntu 18.04 Server, the /etc/resolv.conf file is no longer edited directly. It is a symlink managed by the systemd-resolved service. The correct way to configure DNS is through Netplan, the default network management tool on Ubuntu 18.04.
Netplan stores its configuration as YAML files in /etc/netplan/. Common filenames are 01-netcfg.yaml and 50-cloud-init.yaml. Open your configuration file:
bashsudo nano /etc/netplan/01-netcfg.yaml
A typical file looks like this:
yamlnetwork: version: 2 renderer: networkd ethernets: ens3: dhcp4: no addresses: - 192.168.121.199/24 gateway4: 192.168.121.1 nameservers: addresses: [8.8.8.8, 8.8.4.4]
Change the addresses values under nameservers to your preferred DNS servers. For Cloudflare:
yaml nameservers: addresses: [1.1.1.1, 1.0.0.1]
If the nameservers block does not exist in your file, add it under the interface name block. Pay close attention to indentation — YAML is whitespace-sensitive, and a misaligned line will cause Netplan to fail when you apply the configuration.
Apply the changes:
bashsudo netplan apply
Netplan generates the configuration for the systemd-resolved service automatically. Verify the new DNS servers are active:
bashsystemd-resolve --status | grep 'DNS Servers' -A2
Output:
DNS Servers: 1.1.1.1 1.0.0.1
Changing your DNS nameservers on Ubuntu 18.04 takes just a few minutes on both the desktop and the server. Whether you switch for better speed, privacy, or reliability, Cloudflare and Google DNS are solid starting points. Leave a comment below if you run into any issues.