- March 5, 2023
- 11:21 pm
- No Comments
How to Change DNS Server on Linux
bChanging the DNS (Domain Name System) server on Linux is a simple process that can be done using the command line interface. This can be useful if you want to use a specific DNS server to improve your internet speed or security. In this article, we will discuss how to change the DNS server on Linux.
There are different ways to change the DNS server on Linux, but the most common method is to modify the configuration file of the network manager.
Debian/Ubuntu-based distros
Step 1: Open Terminal
Open the terminal by pressing Ctrl + Alt + T on your keyboard or by searching for it in the applications menu.
Step 2: Edit resolv.conf
Edit the /etc/resolv.conf file using a text editor such as nano or vim. This file contains the current DNS configuration of your system. To edit the file, run:
sudo nano /etc/resolv.conf
Find the line that starts with “nameserver” and replace the IP address with the IP address of the DNS server you want to use.
You can use multiple DNS servers by adding additional “nameserver” lines. For example, if you want to use Google’s DNS server (8.8.8.8), you can replace the line with:
nameserver 8.8.8.8
Step 3: Save Changes
Press Ctrl + X to exit nano and then press “Y” to save the changes. If you used a different text editor, use its save and exit functions.
Step 4: Restart Network Manager
Restart the network manager by running:
sudo systemctl restart network-manager.service
This will apply the changes you made to the DNS configuration.
Fedora/RPM-based distros
Step 1: Open Terminal
Open the terminal by pressing Ctrl + Alt + T on your keyboard or by searching for it in the applications menu.
Step 2: Edit resolv.conf
Edit the /etc/resolv.conf file using a text editor such as nano or vim. This file contains the current DNS configuration of your system. To edit the file, run:
sudo nano /etc/resolv.conf
Find the line that starts with “nameserver” and replace the IP address with the IP address of the DNS server you want to use.
You can use multiple DNS servers by adding additional “nameserver” lines. For example, if you want to use Google’s DNS server (8.8.8.8), you can replace the line with:
nameserver 8.8.8.8
Step 3: Save Changes
Press Ctrl + X to exit nano and then press “Y” to save the changes. If you used a different text editor, use its save and exit functions.
Step 4: Restart Network Manager
Restart the network manager by running:
sudo systemctl restart network.service
This will apply the changes you made to the DNS configuration.
Arch-based distros
Step 1: Open Terminal
Open the terminal by pressing Ctrl + Alt + T on your keyboard or by searching for it in the applications menu.
Step 2: Edit resolv.conf
Edit the /etc/systemd/resolved.conf file using a text editor. This file contains the current DNS configuration of your system. To edit the file, run:
sudo nano /etc/systemd/resolved.conf
Uncomment the line that starts with “DNS=” and replace the IP address with the IP address of the DNS server you want to use. You can use multiple DNS servers by separating them with a space. For example, if you want to use Google’s DNS server (8.8.8.8), you can replace the line with:
DNS=8.8.8.8
Step 3: Save Changes
Press Ctrl + X to exit nano and then press “Y” to save the changes. If you used a different text editor, use its save and exit functions.
Step 4: Restart systemd Resolved Service
Restart the systemd-resolved service by running:
sudo systemctl restart systemd-resolved.service
This will apply the changes you made to the DNS configuration.
Conclusion
In conclusion, changing the DNS server on Linux is a simple process that can be done using the command line interface. It is important to note that the changes you make to the DNS configuration will only affect the computer you are working on. If you want to change the DNS settings for your entire network, you will need to make changes to your router or DNS server.
Overall, changing the DNS server on Linux can improve your internet speed and browsing experience. By using a reliable and fast DNS server, you can avoid delays caused by slow DNS resolution times and ensure that your web requests are handled efficiently. Whether you are a network administrator or a home user, learning how to change the DNS server on Linux is a valuable skill that can benefit you in many ways.
Please Leave Feedback and Corrections in the Comments
More to Explore
How to Access Google Drive on Ubuntu
Google Drive has become an essential tool for many users, allowing them to store and access files in the cloud and collaborate with others.
10 Linux Terms You Must Know
When getting started with Linux, you’ll encounter a variety of unique terms and concepts that are crucial to understanding the Linux ecosystem.
How to Check Hardware Information on Linux
Getting detailed information about your Linux system’s hardware is essential for troubleshooting, optimizing performance, and upgrading components.
How to Run Android on Ubuntu
Running Android on Linux can be a useful way to access Android apps and games on your Linux machine or test and develop Android applications.
How to Listen to Internet Radio on Linux
Internet radio offers a vast array of music, news, and talk stations from around the world.
How to Recover Deleted Files on Linux
Accidentally deleting important files is a common issue that many users face.
How to Access a Remote Linux Machine From Windows
Accessing a remote Linux machine from a Windows computer can be a useful skill for various tasks.
7 Mistakes New Linux Users Make
Linux is a powerful and versatile operating system that offers a wealth of benefits, including increased security, flexibility, and customization.
How to View WebP Images on Ubuntu
WebP is an image format developed by Google that provides superior compression and faster loading times compared to other image formats.