How to Change DNS Settings on Linux - Evoxt
Login
Register
We care about the Environment

How to Change DNS Settings on Linux

In this guide on How to Change DNS on Linux, we will show you how to update your DNS settings to improve network performance, enhance security, and speed up domain resolution. Whether you are switching to Google DNS, Cloudflare, or using custom nameservers, these steps ensure a smooth transition. For more information on DNS fundamentals, visit the Cloudflare DNS Learning Center.

Step 1: Open the DNS Configuration File

Use a text editor like nano to open the DNS configuration file:

sudo nano /etc/resolv.conf

Step 2: Change Your DNS Settings in Linux

Edit your DNS configuration file using a text editor (for example, nano):
sudo nano /etc/resolv.conf

Replace the existing nameservers with your preferred ones:

  • Google DNS:
    nameserver 8.8.8.8
    nameserver 8.8.4.4
  • Cloudflare DNS:
    nameserver 1.1.1.1
    nameserver 1.0.0.1
Change DNS Settings on Linux

Step 3: Save, Restart, and Verify

Save and exit the file (Press Ctrl + X, then Y to confirm, and Enter). Restart the network service:

  • Ubuntu/Debian:
    sudo systemctl restart networking
  • CentOS:
    sudo systemctl restart NetworkManager
Verify the new DNS settings:
cat /etc/resolv.conf

Quick Commands

sudo nano /etc/resolv.conf
sudo systemctl restart networking
cat /etc/resolv.conf

Learn How to Change DNS Settings on Windows.

High CPU Frequency Virtual Machines

Available Globally

Starting at

$2.99

Deploy now