How To

Set DNS Nameservers on Ubuntu 18.04: Desktop and Server Guide

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:

  • Google: 8.8.8.8 and 8.8.4.4
  • Cloudflare: 1.1.1.1 and 1.0.0.1
  • OpenDNS: 208.67.222.222 and 208.67.220.220
  • Level3: 209.244.0.3 and 209.244.0.4

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.

Set DNS Nameservers on Ubuntu Desktop

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.

Set DNS Nameservers on Ubuntu Server via Netplan

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.

Cyber Defence

Recent Posts

Install phpMyAdmin on Ubuntu 18.04 with Apache: Setup Guide

phpMyAdmin is a free, open-source PHP application that provides a browser-based interface for managing MySQL and…

2 days ago

Install Zabbix on Ubuntu 18.04: Server Setup with MySQL Backend

Zabbix is a mature open-source infrastructure monitoring platform that collects metrics from network devices, servers, virtual…

2 days ago

Install Gradle on Ubuntu 18.04: Set Up OpenJDK and Environment

Gradle is a powerful open-source build automation tool used primarily for Java, Kotlin, Groovy, and Android…

2 days ago

Install TeamViewer on Ubuntu 18.04: Download the .deb and Set Up

TeamViewer is a proprietary cross-platform remote access application for remote control, desktop sharing, file transfer, and online meetings. It is one of the most widely used remote support tools in the world, available for Windows, macOS, Linux, iOS, and Android. TeamViewer is not included in the Ubuntu repositories because it is proprietary software. This guide covers how to install TeamViewer on Ubuntu 18.04 using the official .deb package. The same steps apply to Ubuntu 16.04, Debian, Linux Mint, and Elementary OS. <strong>Prerequisite:</strong>&nbsp;You&nbsp;need&nbsp;sudo&nbsp;access. Install TeamViewer on Ubuntu: Download the .deb Package Download the official TeamViewer .deb package. The _amd64.deb suffix indicates this package is for 64-bit x86-64 systems. For ARM-based machines, download the appropriate package from the TeamViewer Linux downloads page: bashwget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb Install the package using apt. The ./ prefix tells apt this is a local file path, not a package name from the repositories:…

2 days ago

Install Nagios Core on Ubuntu 18.04: Build from Source Guide

Nagios is one of the most widely used open-source infrastructure monitoring systems in the world. It…

2 days ago

Install Laravel on Ubuntu 18.04 with Composer: Setup Guide

Laravel is an open-source PHP web application framework built around an expressive, developer-friendly syntax. It is…

3 days ago