Updating resolv.conf on Linux with Google DNS
The resolv.conf file is a vital component on Linux systems that specifies the DNS servers used to resolve domain names into IP addresses. Sometimes you need to update this file to use reliable DNS servers, such as Google’s. This step‑by‑step guide shows how to do it safely.
First, check if systemd-resolved is active
systemd-resolved is a DNS resolver service provided by systemd, commonly used in modern Linux distributions. Before changing resolv.conf, ensure that systemd-resolved is in use to keep DNS settings compatible and working.
Check its status:
sudo systemctl status systemd-resolved
If the service is active and running, you’ll see output indicating “active (running)”. If not, enable and start it:
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved
Step 1: Open resolv.conf
Open the file with your preferred editor (Vim, Nano, Gedit, etc.):
sudo vim /etc/resolv.conf
Step 2: Make the changes
Replace the current nameservers with Google’s DNS servers:
nameserver 8.8.8.8
nameserver 8.8.4.4
Step 3: Save and close the file
In Vim, press Esc, then type :wq and press Enter. Follow your editor’s instructions otherwise.
Step 4: Verify the changes
Use cat to confirm the new configuration:
cat /etc/resolv.conf
You should see the new Google DNS servers listed.
Conclusion
Updating resolv.conf on Linux to use Google’s DNS servers is simple and helps ensure fast, reliable name resolution. By following this guide, you can configure your system with confidence.