When you connect your Ubuntu machine to a new Wi-Fi network, your router automatically assigns it a default Domain Name System (DNS) server—usually one operated directly by your Internet Service Provider (ISP). Unfortunately, ISP-provided DNS servers are notoriously slow, prone to frustrating outages, and frequently used to log your browsing history for targeted advertising. If you want faster page load times and enhanced privacy, you must learn how to change DNS servers in Ubuntu Linux to a reputable third-party provider.
In this comprehensive networking guide, we will explore why upgrading your DNS is crucial for security, provide step-by-step instructions for the standard GNOME graphical interface, and offer the terminal command method for server administrators.
Why Should You Change Your DNS?
The DNS acts as the phonebook of the internet. When you type a human-readable address like digitash.com into Firefox, your computer queries the DNS server to translate that name into a machine-readable IP address so it can locate the server.
Changing to a public DNS provider (like Cloudflare, Google, or Quad9) offers three massive benefits:
- Speed: Public providers operate massive global networks. Because they process billions of requests daily, their caches are incredibly efficient, resolving web addresses milliseconds faster than your local ISP.
- Reliability: If your ISP’s DNS goes down, you will lose internet access entirely (even if the underlying connection is fine). Public DNS servers boast 99.99% uptime.
- Privacy & Security: Providers like Cloudflare (1.1.1.1) and Quad9 (9.9.9.9) strictly promise not to log your IP address or sell your browsing data. Furthermore, they actively block known malicious domains, providing a first layer of defence against phishing attacks.
Recommended Public DNS Servers
Before proceeding, choose which provider you want to use. You will need their primary and secondary IPv4 addresses:
- Cloudflare (Best for Speed & Privacy):
1.1.1.1and1.0.0.1 - Google (Highly Reliable):
8.8.8.8and8.8.4.4 - Quad9 (Best for Malware Blocking):
9.9.9.9and149.112.112.112
Method 1: Changing DNS via the Graphical Interface (GUI)
If you are using the standard Ubuntu Desktop environment (GNOME), changing your DNS is incredibly straightforward and does not require touching the terminal.
Step 1: Open Network Settings
Look at the top-right corner of your screen and click on the network status icons (Wi-Fi, volume, battery) to open the system menu. Click on the Settings icon (the gear).
In the Settings window sidebar, click on Wi-Fi (or Network if you are using a wired Ethernet connection).
Step 2: Edit the Connection Profile
Locate the specific network you are currently connected to. Click on the small gear icon next to the network name to edit its properties.
Note: DNS settings are tied to the specific network profile. If you set a custom DNS for your home Wi-Fi, it will revert to default when you connect to a coffee shop Wi-Fi until you configure that profile as well.
Step 3: Override the Automatic DNS
A dialogue box will appear. Click on the IPv4 tab at the top.
- Look for the section labelled “DNS”. Next to it, you will see a toggle switch labelled Automatic.
- Toggle this switch OFF. This prevents your router from overwriting your custom settings.
- A text box will now become active. Enter the primary and secondary DNS addresses of your chosen provider, separated by a single comma. For example, to use Cloudflare, type exactly:
1.1.1.1, 1.0.0.1
Step 4: Apply and Reconnect
Click the green Apply button in the top right corner. For the new DNS settings to take effect immediately, you must reset the connection. Simply toggle the Wi-Fi switch off and then back on again to reconnect to the network.
Method 2: Changing DNS via the Terminal (Netplan)
If you are running Ubuntu Server without a graphical interface, you must configure your DNS by editing the Netplan configuration files.
Step 1: Locate the Netplan File
Open your terminal and list the contents of the Netplan directory:
ls /etc/netplan/
You will see a `.yaml` file, typically named something like 01-netcfg.yaml or 00-installer-config.yaml.
Step 2: Edit the Configuration File
Open the file using the Nano text editor (requires sudo privileges):
sudo nano /etc/netplan/01-netcfg.yaml
Locate your active network interface (e.g., eth0 or enp3s0). You need to add a nameservers block beneath it. The strict YAML indentation is critical. It should look like this:
network:
version: 2
ethernets:
enp3s0:
dhcp4: true
nameservers:
addresses: [1.1.1.1, 1.0.0.1]
Step 3: Apply the Changes
Save the file by pressing Ctrl + O, Enter, and then Ctrl + X to exit Nano. Finally, apply the new network configuration by running:
sudo netplan apply
Frequently Asked Questions
How do I verify my new DNS is working?
You can verify your system is using the new resolver by opening the terminal and using the resolvectl command. Run resolvectl status and look for the “Current DNS Server” line under your active network interface link.
Will changing my DNS break my internet?
If you enter the IP addresses incorrectly, or if the public DNS provider experiences a rare outage, your browser will be unable to load websites (returning a “DNS_PROBE_FINISHED_BAD_CONFIG” error). If this happens, simply return to the network settings, toggle the DNS switch back to “Automatic”, and apply. Your internet will instantly restore using your ISP’s default servers.
Relying on your ISP for domain resolution is an unnecessary compromise on privacy and speed. By taking two minutes to change DNS servers in Ubuntu Linux, you instantly upgrade your entire web browsing experience, ensuring your requests are resolved quickly, securely, and privately.