How to Configure DNS on Ubuntu: Netplan and NetworkManager Explained

1. Introduction: Why DNS Configuration Matters on Ubuntu

DNS (Domain Name System) is the mechanism that converts domain names into IP addresses.
Every time we open a website, the operating system silently performs DNS queries in the background.

When using Ubuntu, you may experience situations such as:

  • Pages feeling “somehow slow” to load
  • The same network feeling slower than other devices
  • Occasional inability to access internal web services on a LAN

Surprisingly often, these issues are not caused by connection quality but by slow DNS resolution.

On Ubuntu, even from version 22.04 onward, one confusing point for beginners is that there are multiple ways to configure DNS. In particular, there are two major approaches:

  • Netplan (commonly used on servers and non-GUI environments)
  • NetworkManager (used on desktop environments with a GUI)

Because the procedure differs depending on which method is in use, any guide on DNS configuration for Ubuntu must first identify the environment and then guide you to the appropriate method.

DNS is not just a minor setting—it is the “entry point” of the entire network stack on Ubuntu.

For example, simply switching to Google Public DNS (8.8.8.8) or Cloudflare (1.1.1.1) can noticeably improve browser responsiveness.
This effect is especially clear in VPS, cloud, and overseas network environments.

In this article, we will clearly separate and explain:

  • How to configure DNS using a GUI
  • How to configure DNS using Netplan
  • How to verify your settings afterward

In the next section, we start by determining which type of environment you are using.

2. Two Major Ways to Configure DNS on Ubuntu

On Ubuntu, even though the goal is “DNS configuration,” the actual method differs depending on the network management system in use.
If you proceed without understanding this distinction, you may encounter issues such as settings not applying or reverting after a reboot.

First, let’s clarify that there are two distinct DNS configuration paths on Ubuntu.

Netplan (YAML-based configuration)

  • Primarily used for server environments
  • Standardized across Ubuntu LTS releases from 18.04 onward
  • Configuration files are located at /etc/netplan/*.yaml
  • Works in conjunction with systemd-resolved

On VPS instances or physical servers without a GUI, Netplan is almost always the correct assumption.
This is common on AWS, Vultr, ConoHa, Oracle Cloud, and similar platforms.

NetworkManager (GUI-based)

  • Primarily used on desktop PCs (Ubuntu Desktop)
  • DNS can be specified via IPv4 / IPv6 settings screens
  • Easy to understand thanks to a visual interface

If you are using a GUI-enabled environment, this is the most likely setup.
Typical cases include “I use Ubuntu daily and just want to change DNS because browsing feels slow.”

Determine Which Environment You Are Using

The simplest way to check is to see whether files exist in /etc/netplan/.

ls /etc/netplan/

If you find YAML files, Netplan is likely in use.
If the directory is empty or you are on a GUI-based system, checking NetworkManager settings is the smoother approach.

3. Configuring DNS with Netplan (Server Environments)

Netplan uses YAML files to define network configuration.
In Ubuntu Server and VPS environments without a GUI, this method is almost guaranteed.

Here, we focus on the common case of fixing DNS values, using a minimal and practical example.

Open the Netplan Configuration File

Netplan configuration files are located in /etc/netplan/.
The file name varies by environment (for example, 00-installer-config.yaml).

First, confirm the file name:

ls /etc/netplan/

Once identified, open the file in an editor. For example:

sudo nano /etc/netplan/00-installer-config.yaml

Example: Adding DNS Entries in YAML

This example sets both Google DNS and Cloudflare DNS.

network:
  version: 2
  ethernets:
    ens33:
      dhcp4: true
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]

The interface name ens33 varies by system.
Check it using ip a or ip link.

Apply the Configuration

After editing, apply the configuration immediately:

sudo netplan apply

If errors occur, indentation issues in the YAML file are the most common cause.
Check spacing carefully. Tabs are not allowed.

Can DHCP and Fixed DNS Be Used Together?

This is a common question. Yes, it is possible to obtain IP addresses via DHCP while manually specifying DNS servers.

Example:

dhcp4: true
nameservers:
  addresses: [9.9.9.9]

In this case, IP addresses are automatic, while DNS is fixed.

4. Using NetworkManager (Ubuntu Desktop)

If you are using Ubuntu for desktop purposes, you can change DNS settings without using the terminal.
For common cases such as “only the browser feels slow” or “I just want to switch to a public DNS,” the GUI approach is the fastest.

How to Open the Settings Screen

  1. Click the network icon in the top-right corner
  2. Open “Settings” or “Network Settings”
  3. Select the active connection (wired or Wi-Fi)
  4. Go to the “IPv4” tab

The DNS input field is located here.
The exact wording may differ slightly by Ubuntu version, but addresses can be entered as a comma-separated list.

Example DNS Input (IPv4)

Example using Google DNS and Cloudflare DNS:

8.8.8.8, 1.1.1.1

After entering the values, click “Apply” or “Save,” and reconnect the network to ensure changes take effect.

When Using IPv6

The same screen includes an “IPv6” tab with DNS input fields.
On dual-stack connections, stability may require specifying DNS for both IPv4 and IPv6.

Combining DHCP with Fixed DNS

Even in the GUI, you can configure “automatic IP, manual DNS.”
This is especially useful on home or office Wi-Fi where you do not want to manually assign a fixed IP each time.

5. How to Verify That DNS Settings Are Applied

DNS configuration is not complete just because you entered and saved values.
Verification is essential to confirm that the settings are actually in effect.

On Ubuntu, you can verify DNS using the following three methods.

Query Using the dig Command

dig google.com

Look for the line labeled “SERVER:” in the output.
It indicates which DNS server is currently being queried.

Example (excerpt):

;; SERVER: 8.8.8.8#53(8.8.8.8)

Check that this shows 8.8.8.8 (Google) or 1.1.1.1 (Cloudflare).

Using resolvectl status

This method provides accurate information via systemd-resolved.

resolvectl status

The currently referenced nameservers are displayed per network interface.
On servers with multiple NICs, this method is more reliable than dig.

Why You Should Not Edit /etc/resolv.conf Directly

cat /etc/resolv.conf

This file shows the DNS currently in use.
However, it is a generated result file created by systemd-resolved.
Any manual edits will be overwritten, so modifying it directly is incorrect.

6. Commonly Used DNS Providers (Beginner-Friendly)

DNS addresses are not something you invent yourself.
In most cases, public DNS services are used.

If you want a stable and safe starting point, any of the following are good choices:

ProviderDNS Address
Google Public DNS8.8.8.8 / 8.8.4.4
Cloudflare1.1.1.1
Quad99.9.9.9
OpenDNS208.67.222.222 / 208.67.220.220

Specifying two DNS servers instead of one increases reliability.
If one becomes unavailable, the system automatically falls back to the other.

When accessing internal corporate systems (such as Active Directory), you must use internal DNS servers instead.
In such cases, ensuring reliable internal name resolution takes priority over public DNS.

7. DNS Is Often a Hidden Bottleneck

Although DNS looks like just another setting, it has a major impact on perceived network speed.
Its influence becomes especially obvious in the following situations:

  • The very first page load feels unusually slow
  • Ping is fast, but web pages load slowly
  • The server is light, but initial SPA (React / Vue) loads are heavy

These symptoms typically improve after repeated access, while the first request remains slow.
This is because DNS acts as the initial gateway.

Especially on VPS or overseas regions (such as us-east or eu-west), public DNS often outperforms ISP default DNS.

DNS is a point where network congestion-induced latency easily appears.
Not only on Ubuntu, but for web engineers in general, DNS optimization is one of the first “entry point” optimizations to consider.

FAQ

Q1: I edited /etc/resolv.conf directly, but it reverts after reboot. Why?
→ On Ubuntu, systemd-resolved generates /etc/resolv.conf.
It is not meant to be edited directly.
You must configure DNS via Netplan or NetworkManager.

Q2: What if I don’t know whether Netplan or NetworkManager is in use?
→ First, check /etc/netplan/.

ls /etc/netplan/

If YAML files exist, Netplan is likely in use.
In GUI environments, NetworkManager is the primary candidate.

Q3: Can I use DHCP for IP while fixing DNS?
→ Yes.
Both Netplan and NetworkManager support automatic IP with manually specified DNS.

Q4: Will changing DNS always make the web faster?
→ Not always.
DNS handles only the initial name resolution.
It often speeds up the first step, but slow images, CDNs, or APIs can still be bottlenecks.

Q5: Is the procedure the same for WSL2 (Ubuntu on Windows)?
→ No.
WSL2 regenerates resolv.conf by design.
Additional settings such as generateResolvConf=false are required.
WSL has its own DNS configuration considerations.