How to Set DNS to 8.8.8.8 in Linux?
![How to Set DNS to 8.8.8.8 in Linux?](/static/img/files/linux.webp)
In the vast realm of Linux, configuring DNS settings is a routine task for users seeking optimal internet connectivity. One popular DNS option is Google's public DNS server, which is easily accessible via the IP address 8.8.8.8. This article will guide you through the process of setting your DNS to 8.8.8.8 in a Linux environment, ensuring a smooth and efficient browsing experience.
Check Current DNS Settings:
Before making any changes, it's prudent to check your current DNS settings. Open a terminal and enter the following command:cat /etc/resolv.conf
This will display your current DNS configuration.
Backup Your Current DNS Configuration:
While making changes, it's a good practice to create a backup. You can use the 'cp' command to duplicate your existing resolv.conf file:sudo cp /etc/resolv.conf /etc/resolv.conf.backup
Edit the resolv.conf File:
To set the DNS to 8.8.8.8, open the resolv.conf file in a text editor. We'll use nano in this example:sudo nano /etc/resolv.conf
Update DNS Configuration:
In the resolv.conf file, locate the line starting with 'nameserver' and replace the existing IP address with 8.8.8.8:nameserver 8.8.8.8
Save the changes and exit the text editor.
Verify the Changes:
Confirm that the changes have taken effect by once again using the 'cat' command on the resolv.conf file:cat /etc/resolv.conf
Restart Networking Services:
For the changes to be applied, restart your networking services. The exact command may vary based on your Linux distribution:- For systems using systemd:
sudo systemctl restart NetworkManager
- For systems using init.d:
sudo service networking restart
- For systems using systemd:
More Examples:
Using NetworkManager Command Line Interface (nmcli):
If you prefer a command-line approach, you can use 'nmcli' to modify your DNS settings:sudo nmcli con mod <connection-name> ipv4.dns "8.8.8.8"
Setting DNS in Ubuntu:
Ubuntu users can also update the DNS settings via the network configuration file:sudo nano /etc/network/interfaces
Add the following line:
dns-nameservers 8.8.8.8
Related Searches and Questions asked:
That's it for this topic, Hope this article is useful. Thanks for Visiting us.