Software & AppsOperating SystemLinux

How To Permanently Change DNS Server on Ubuntu 20.04

Ubuntu 17

In this guide, we will walk you through the process of permanently changing your DNS server on Ubuntu 20.04. Changing your DNS server can help you improve your internet speed, enhance security, and even bypass censorship filters.

Quick Answer

To permanently change the DNS server on Ubuntu 20.04, you can either use the Network Manager GUI or the terminal. Using the GUI, you can easily modify the DNS server settings for your connection. If you prefer the terminal, you can install the resolvconf package, enable the resolvconf.service, edit the DNS configuration file, and update the DNS settings.

What is a DNS Server?

DNS (Domain Name System) is a service that translates human-friendly domain names (like www.google.com) into IP addresses that computers use to talk to each other. DNS servers are like an internet phone book that your computer uses to look up these addresses.

Why Change Your DNS Server?

The default DNS servers provided by your ISP (Internet Service Provider) are not always the fastest or most reliable. Some alternative DNS servers, such as Google DNS (8.8.8.8, 8.8.4.4) and Cloudflare DNS (1.1.1.1), offer improved performance and better privacy.

Method 1: Changing DNS Server via Network Manager GUI

This is the easiest method for those who prefer a graphical interface.

  1. Open Network Manager: Click on the network icon in the system tray and select “Edit Connections.”
  2. Select the Connection: Choose the connection (Wired or Wireless) that you want to modify and click “Edit.”
  3. Change the Settings: In the IPv4 Settings tab, change the method to “Automatic (DHCP) addresses only.” This setting will allow your computer to automatically obtain an IP address from the router, but use the DNS servers you specify.
  4. Enter DNS Servers: In the “DNS servers” field, enter the addresses of the DNS servers you want to use, separated by commas (e.g., 8.8.8.8, 8.8.4.4 for Google DNS).
  5. Save Changes: Click “Apply” to save the changes. You may need to disconnect and reconnect to the network for the changes to take effect.

Method 2: Changing DNS Server via Terminal

For those who prefer using the terminal, here’s how to change your DNS server via the command line.

  1. Install resolvconf Package: Run the command sudo apt install resolvconf to install the resolvconf package. This package is used to manage the DNS resolution system in Ubuntu.
  2. Enable resolvconf.service: Run the command sudo systemctl enable --now resolvconf.service to enable and start the resolvconf service. This service ensures that your DNS settings are applied every time your system boots.
  3. Edit DNS Configuration File: Use a text editor like nano or vim to edit the /etc/resolvconf/resolv.conf.d/head file by running sudo nano /etc/resolvconf/resolv.conf.d/head or sudo vim /etc/resolvconf/resolv.conf.d/head.
  4. Add DNS Servers: In the file, add the following lines, replacing the IP addresses with the DNS servers you want to use:
nameserver 8.8.8.8
nameserver 8.8.4.4
  1. Save and Exit: Save the file and exit the text editor. In nano, you can do this by pressing Ctrl+X, then Y, then Enter.
  2. Update DNS Settings: Run the command sudo resolvconf -u to update your DNS settings.

Now, your DNS server should be permanently changed to the ones you specified. You can verify this by running the command systemd-resolve --status, which will display your current DNS servers.

Conclusion

Changing your DNS server can significantly improve your internet experience. Whether you prefer a GUI or the command line, Ubuntu 20.04 makes it easy to change your DNS server. Just remember to choose a reliable DNS server that respects your privacy and provides fast performance.

How do I check my current DNS server on Ubuntu 20.04?

To check your current DNS server on Ubuntu 20.04, you can run the command systemd-resolve --status in the terminal. It will display your current DNS servers.

Can I use multiple DNS servers at the same time?

Yes, you can use multiple DNS servers at the same time. When specifying DNS servers, you can separate them with commas (e.g., 8.8.8.8, 8.8.4.4). Your system will try to use them in the order you specify, falling back to the next one if the previous one is not available.

How do I revert back to the default DNS server settings?

To revert back to the default DNS server settings on Ubuntu 20.04, you can either remove the DNS server addresses you added or change the connection settings back to "Automatic (DHCP)". Remember to save the changes and reconnect to the network for them to take effect.

Can I use DNS-over-HTTPS (DoH) with Ubuntu 20.04?

Yes, you can use DNS-over-HTTPS (DoH) with Ubuntu 20.04. DoH encrypts your DNS queries, providing an extra layer of privacy and security. There are several DoH clients available for Ubuntu, such as cloudflared and dnscrypt-proxy. You can follow their respective documentation to set up DoH on your system.

Are there any other popular alternative DNS servers besides Google DNS and Cloudflare DNS?

Yes, besides Google DNS (8.8.8.8, 8.8.4.4) and Cloudflare DNS (1.1.1.1), there are other popular alternative DNS servers you can use. Some examples include OpenDNS (208.67.222.222, 208.67.220.220), Quad9 (9.9.9.9, 149.112.112.112), and AdGuard DNS (94.140.14.14, 94.140.15.15). These DNS servers offer various features and levels of security, so you can choose the one that best suits your needs.

Leave a Comment

Your email address will not be published. Required fields are marked *