Your cart is currently empty!
How to Change Your DNS Server on Ubuntu
Changing your DNS (Domain Name System) server can speed up browsing, improve reliability, and even boost privacy. Here’s a straight-forward guide to switching your DNS on Ubuntu—whether you’re running the desktop edition with Network Manager or a headless server using Netplan.
Why Change Your DNS?
- Performance: Third-party DNS providers like Google (8.8.8.8), Cloudflare (1.1.1.1), or OpenDNS (208.67.222.222) often respond faster than your ISP’s default.
- Reliability: If your ISP’s DNS goes down, you won’t be stuck offline.
- Privacy & Security: Some public DNS services offer malware filtering or DNS over HTTPS/TLS options.
Prerequisites
- Ubuntu 18.04 LTS or later (desktop/server)
- sudo or root access
- Familiarity with the terminal (for server setups)
Method 1: Ubuntu Desktop (Network Manager GUI)
- Open Settings
- Click the system menu (top-right), choose Settings → Network.
- Edit Your Connection
- Select Wired or Wi-Fi, then click the gear icon next to your active connection.
- Adjust DNS
- Go to the IPv4 (and/or IPv6) tab.
- Change Automatic (DHCP) to Automatic (DHCP) addresses only.
- In the DNS field, enter your preferred servers, comma-separated (e.g.,
1.1.1.1, 8.8.8.8
).
- Save & Reconnect
- Click Apply, then toggle the connection off and on again.
- Confirm with
systemd-resolve --status
ornmcli dev show | grep DNS
.
Method 2: Ubuntu Server (Netplan)
Ubuntu server editions (18.04+) use Netplan to manage networking.
- Locate Your Netplan Config
ls /etc/netplan/
You’ll see a.yaml
file, e.g.01-netcfg.yaml
. - Edit the YAML
sudo nano /etc/netplan/01-netcfg.yaml
Under your network interface (e.g.,eth0
), add or update:network: version: 2 ethernets: eth0: dhcp4: true nameservers: addresses: - 1.1.1.1 - 8.8.8.8
- Apply Changes
sudo netplan apply
- Verify
systemd-resolve --status | grep 'DNS Servers'
Method 3: Legacy Systems (/etc/resolv.conf
or resolvconf
)
Older Ubuntu releases or custom setups may rely on /etc/resolv.conf
.
- Open resolv.conf
sudo nano /etc/resolv.conf
- Add Your DNS
Place at the top:nameserver 1.1.1.1 nameserver 8.8.8.8
- Lock the File (Optional)
Prevent overwrites by Network Manager or DHCP:sudo chattr +i /etc/resolv.conf
Tip: If you’re using
resolvconf
- Edit
/etc/resolvconf/resolv.conf.d/base
instead, then runsudo resolvconf -u
.
Troubleshooting & Tips
- DNS Cache: Flush with
sudo systemd-resolve --flush-caches
. - Testing:
dig ubuntu.com @1.1.1.1
- Fallbacks: Always list at least two servers in case one fails.
Switching your DNS server can be done in under five minutes—and the payoff in speed and reliability makes it well worth the effort. Try different providers to see which one feels snappiest for your region, and enjoy a faster, more reliable Ubuntu experience!
Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!