How to Change DNS Servers in Ubuntu to Cloudflare or Google DNS for Faster Browsing

Whenever you type a website domain into your web browser, your computer relies on the Domain Name System (DNS) to translate that human-readable address into a numerical IP address. By default, Ubuntu inherits DNS resolvers automatically assigned by your internet service provider (ISP) via your local Wi-Fi router. However, default ISP DNS servers are frequently sluggish, poorly optimized, vulnerable to regional DNS hijacking, and often log your domain browsing history for commercial profiling.

Switching your Ubuntu desktop to high-performance, privacy-respecting public DNS resolvers—such as Cloudflare DNS (1.1.1.1) or Google Public DNS (8.8.8.8)—delivers faster web page lookup speeds, reduces connection latency, and improves security against malicious phishing domains. This tutorial explains how to configure custom DNS servers in Ubuntu through both the graphical control centre and the command line.

Reliable Public DNS Server IP Addresses

Before modifying your network configuration, select your preferred primary and secondary DNS providers:

  • Cloudflare DNS (Privacy & Speed):
    • IPv4: 1.1.1.1 and 1.0.0.1
    • IPv6: 2606:4700:4700::1111 and 2606:4700:4700::1001
  • Google Public DNS (Global Reliability):
    • IPv4: 8.8.8.8 and 8.8.4.4
    • IPv6: 2001:4860:4860::8888 and 2001:4860:4860::8844

Changing DNS Servers in Ubuntu Graphical Settings

On modern releases of Ubuntu (including 22.04 LTS and 24.04 LTS), updating DNS resolvers takes less than two minutes:

  1. Click the System Menu in the top-right corner of your desktop panel and open Settings.
  2. In the left sidebar, click Wi-Fi (or Network if you use an Ethernet cable).
  3. Locate your active network connection and click the Gear icon beside its name.
  4. In the network details dialogue that opens, click on the IPv4 tab at the top.
  5. Find the DNS section. Toggle the Automatic switch to Off.
  6. In the text box beneath, enter your custom DNS addresses separated by a comma. For Cloudflare, enter:
    1.1.1.1, 1.0.0.1
  7. Click on the IPv6 tab at the top. If IPv6 is active, toggle Automatic to Off and enter:
    2606:4700:4700::1111, 2606:4700:4700::1001
  8. Click the green Apply button in the top right corner.
  9. To activate the changes immediately, toggle your Wi-Fi or Ethernet connection off and back on using the quick switch.

Changing DNS Servers via Terminal Using nmcli

If you are administering headless servers or prefer keyboard management, you can configure DNS using NetworkManager’s CLI utility, nmcli:

  1. Open the Terminal (Ctrl + Alt + T).
  2. List active network connections to identify your connection name:
    nmcli connection show --active
  3. Set Cloudflare DNS for your connection (replace “YourConnectionName” with your actual profile name, e.g. “Wired connection 1”):
    sudo nmcli connection modify "YourConnectionName" ipv4.dns "1.1.1.1 1.0.0.1"
    sudo nmcli connection modify "YourConnectionName" ipv4.ignore-auto-dns yes
  4. Restart the network interface:
    sudo nmcli connection up "YourConnectionName"

Verifying Your Active DNS Configuration

To confirm that Ubuntu is actively resolving queries through your new servers:

  1. In the Terminal, execute:
    resolvectl status
  2. Scroll down to your active link. Under Current DNS Server and DNS Servers, verify that 1.1.1.1 or 8.8.8.8 is listed.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.