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:
Step 3: Save, Restart, and Verify
Save and exit the file (Press Ctrl + X, then Y to confirm, and Enter). Restart the network service:
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.