RackNerd Billboard Banner

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?

  1. 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.
  2. Reliability: If your ISP’s DNS goes down, you won’t be stuck offline.
  3. 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)

  1. Open Settings
    • Click the system menu (top-right), choose SettingsNetwork.
  2. Edit Your Connection
    • Select Wired or Wi-Fi, then click the gear icon next to your active connection.
  3. 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).
  4. Save & Reconnect
    • Click Apply, then toggle the connection off and on again.
    • Confirm with systemd-resolve --status or nmcli dev show | grep DNS.

Method 2: Ubuntu Server (Netplan)

Ubuntu server editions (18.04+) use Netplan to manage networking.

  1. Locate Your Netplan Config ls /etc/netplan/ You’ll see a .yaml file, e.g. 01-netcfg.yaml.
  2. 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
  3. Apply Changes sudo netplan apply
  4. 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.

  1. Open resolv.conf sudo nano /etc/resolv.conf
  2. Add Your DNS
    Place at the top: nameserver 1.1.1.1 nameserver 8.8.8.8
  3. 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 run sudo 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!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link