- 1 1. Introduction: Why DNS Configuration Matters on Ubuntu
- 2 2. Two Main Approaches to DNS Configuration on Ubuntu
- 3 3. Procedure to Configure DNS with Netplan (Server-oriented)
- 4 4. In the Case of NetworkManager (GUI) – For Ubuntu Desktop
- 5 5. How to Verify That DNS Settings Have Taken Effect
- 6 6. Common Public DNS Examples (Useful for Beginners)
1. Introduction: Why DNS Configuration Matters on Ubuntu
DNS (Domain Name System) is the mechanism that translates domain names into IP addresses. Whenever we open a new site, the OS always makes a query to DNS behind the scenes.
On Ubuntu, you might experience:
- Page loading feels “somewhat slow”
- Using the same connection, but feels slower than another device
- Occasional failures to access internal web servers on the LAN
These phenomena often stem not from “connection quality” but rather the unexpected “slowness of DNS”.
In Ubuntu’s case, even in version 22.04 and beyond, the fact that “there are multiple ways to configure DNS” is a source of confusion for beginners. In particular, the following two types exist:
- Netplan (mainly used in server builds without GUI)
- NetworkManager (used with desktop-UI setups)
- How to use the GUI method
- How to write settings with Netplan
- How to verify the settings have taken effect
- Predominant in server use
- Standardized from Ubuntu 18.04 through current LTS versions
- Configuration file:
/etc/netplan/*.yaml - Modularly works in conjunction with systemd-resolved
- Mainstream in desktop PCs (Ubuntu Desktop)
- Allows DNS specification via IPv4/IPv6 settings screen
- UI exists for applying settings, making it easier to understand
Because operations change depending on which one you’re using, any article dealing with DNS configuration on Ubuntu must begin with “determine the environment” followed by “guide to the appropriate method”.
Also, DNS is not merely “one setting among many” but the “entry point” to the entire network of Ubuntu.
For example, switching to Google Public DNS (8.8.8.8) or Cloudflare (1.1.1.1) alone may noticeably improve browser performance. This is especially pronounced in VPS, cloud, or overseas-facing network environments.
In the sections below, this article will clearly divide into:
The next section will begin by determining which environment you’re using.
2. Two Main Approaches to DNS Configuration on Ubuntu
On Ubuntu, even with the same “DNS configuration,” the method differs depending on the network management system in use. If you proceed without understanding this difference, the settings may not be applied, or they may revert to unintended values after reboot — leading to trouble.
Here we first clarify the fact that there are “two major branches” for DNS configuration methods on Ubuntu.
Netplan (YAML-based configuration)
In VPS or physical server environments without GUI, first suspect Netplan. This pattern is also common in cloud environments such as AWS, Vultr, ConoHa, Oracle Cloud, etc.
NetworkManager (GUI)
In environments where GUI is available, this is often the first possibility you should check. Especially for cases like “I use Ubuntu casually, the browser seems a little slow and I just want to change DNS”.
First: Determine which environment you are using
The easiest determination method is to check for files under /etc/netplan/.
ls /etc/netplan/
If YAML files are found, chances are high that you’re configured via Netplan. If it’s an empty directory, or you are using a GUI environment, then check the NetworkManager settings screen for a smoother process.
3. Procedure to Configure DNS with Netplan (Server-oriented)
Netplan writes network settings in YAML format. In Ubuntu Server or VPS environments, or other non-GUI setups, this is almost certainly the method you’ll use.
Here we focus on the case of “locking DNS to specific values” and illustrate the procedure with a minimal practical example.
Open the Netplan configuration file
The Netplan configuration file is located in /etc/netplan/.
File names vary by environment (for example: 00-installer-config.yaml).
First check its existence using:
ls /etc/netplan/
Once you confirm the file name, open it in your editor. Example below:
sudo nano /etc/netplan/00-installer-config.yamlHow to add DNS in YAML (example)
Here we show an example specifying both Google DNS and Cloudflare DNS simultaneously.
network:
version: 2
ethernets:
ens33:
dhcp4: true
nameservers:
addresses: [8.8.8.8, 1.1.1.1]* The ens33 portion varies depending on NIC name.
Check via ip a or ip link.
Apply the configuration
After editing, you can immediately apply it with:
sudo netplan apply
If an error appears, the most probable cause is YAML indentation misalignment. Review spaces and hierarchy (tabs must not be used).
Is DHCP + DNS locking possible?
This is a common question: yes, acquiring IP via DHCP while manually specifying DNS is possible.
Example:
dhcp4: true
nameservers:
addresses: [9.9.9.9]This scenario represents “IP is automatic, DNS is fixed”.
4. In the Case of NetworkManager (GUI) – For Ubuntu Desktop
If you use Ubuntu for desktop purposes, you can change DNS without using the terminal. Especially for general usage like “browser is slow” or “just want to switch public DNS”, this GUI setting is the fastest.
How to open the settings screen
- Click the network icon in the top-right
- Open “Settings” or “Network Settings”
- Select the connection you are using (wired / Wi-Fi)
- Go to the “IPv4” tab
Here you will find the DNS settings field. Depending on the Ubuntu version, the wording may differ slightly, but you can enter addresses in a comma-separated list form.
Example input (specifying DNS with IPv4)
Example: using Google DNS and Cloudflare DNS
8.8.8.8, 1.1.1.1After entering, click “Apply” or “Save”, then for safety reconnect the network once to ensure it takes effect.
If you are using IPv6
On the same screen, switching to the “IPv6” tab also has a DNS input field. In a dual-stack connection, you may need to specify both IPv4 and IPv6 to ensure stability.
Using DHCP with fixed DNS together
In the GUI as well, you can set “IP automatic, DNS manual”. This is especially useful at home or office Wi-Fi where you don’t want to manually assign a fixed IP each time.
5. How to Verify That DNS Settings Have Taken Effect
DNS isn’t something you just enter and save and it’s done. Only after verifying it has taken effect can you say the configuration work is complete.
On Ubuntu, you can verify via the following three methods.
Check with the dig command
dig google.comIn the response, there is a line “SERVER: ~”. This indicates which DNS server is being queried right now.
Example (excerpt):
;; SERVER: 8.8.8.8#53(8.8.8.8)Check whether this is 8.8.8.8 (Google) or 1.1.1.1 (Cloudflare).
resolvectl status
For verification via systemd-resolved, this command is more accurate.
resolvectl status
It shows the nameserver currently being referenced per NIC. On servers with multiple NICs, this is more reliable than dig.
Why you should not edit /etc/resolv.conf directly
cat /etc/resolv.confYou can look here to see “the DNS currently in use”. However, this file is a result file generated by systemd-resolved. If you edit it, it will be overwritten soon, so changing it directly is incorrect.
6. Common Public DNS Examples (Useful for Beginners)
DNS addresses are not “something you design yourself”. Generally, you specify public DNS (open DNS) in most cases.
If your goal is simply “start with something stable”, choosing from the list below is fine.
| Provider | DNS Address |
|---|---|
| Google Public DNS | 8.8.8.8 / 8.8.4.4 |
| Cloudflare | 1.1.1.1 |
| Quad9 | 9.9.9.9 |
| OpenDNS | 208.67.222.222 / 208.67.220.220 |
※ It is safer to specify not just one, but two addresses. (This provides automatic fallback in case one side fails.)
Also, when accessing an internal DNS (such as corporate AD), you must specify the internal-only DNS rather than using the public DNS in the table above. In that case, ensuring internal name resolution takes priority is more important than opting for public DNS first.
7. DNS Is Prone to Becoming the “Bottleneck” of Your Environment
DNS may appear as just “one setting item”, but in reality it significantly influences the perceived network speed. Especially in the following scenarios, the impact of DNS becomes glaringly obvious.
- The very first step of loading a page feels unusually slow
- Ping is fast, yet web page loads feel sluggish
- The server is light, yet initial load of a SPA (React/Vue) feels heavy
These symptoms often show a pattern: after accessing the same URL many times it becomes fast, yet the first access is unusually slow — which exactly reflects DNS being the “first entry point”.
Particularly when running in a VPS or overseas region (for example: us-east / eu-west), it is not unusual for the “public DNS” to produce better results than the ISP’s default DNS.
DNS is a point where delay due to network congestion is easily picked up, and regardless of Ubuntu, it can be said that web engineers should first optimize this “entry point”.
FAQ
Q1: I edited /etc/resolv.conf directly, but it reverts to original after reboot. Why?
→ On Ubuntu, systemd-resolved generates /etc/resolv.conf.
It is not a place to edit.
You must use Netplan or NetworkManager for configuration.
Q2: What if I don’t know whether I’m using Netplan or NetworkManager?
→ First check /etc/netplan/.
ls /etc/netplan/
If YAML files appear, Netplan is likely configured. If you’re using a GUI, NetworkManager is more likely.
Q3: Is it possible to acquire IP via DHCP while fixing only DNS?
→ Yes, it is possible.
Whether using Netplan or NetworkManager, “IP: automatic” and “DNS: manual” is a valid combination.
Q4: If I change DNS, will the web always be faster?
→ Not always.
DNS handles the “initial name resolution”.
While the first step of the initial load may speed up, if the images/CDN/API within the page are slow, those become the bottleneck.
Q5: Are the same procedures applicable for WSL2 (Ubuntu on Windows)?
→ In principle, no.
WSL2 regenerates resolv.conf each time.
Hence separate countermeasures such as setting generateResolvConf=false are required.
WSL has its own DNS-setting know-how.



