- 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
MALIBAL Aon S1 Vs Apple MacBook Pro 13 (M2)
In the competitive landscape of high-performance, thin & light laptops, the MALIBAL Aon S1 and the Apple MacBook Pro 13 (M2) are noteworthy contenders.
How to Set Up and Use a Basic Firewall on Linux
UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables firewall rules on Linux systems.
How to Set Up a VPN Server on Linux
A VPN (Virtual Private Network) provides a secure, encrypted connection between your devices and the internet.
How to Install and Use a Terminal Multiplexer on Linux
A terminal multiplexer is a powerful command-line utility that enables users to manage multiple terminal sessions.
How to Set Up a Basic Samba Server on Linux
Samba is a popular open-source software suite that provides seamless file and print services to SMB/CIFS clients.
How to Create and Manage Users and Groups on Linux
User and group management is an essential aspect of maintaining a secure and organized Linux system.
How to Install and Configure a LAMP Stack on Linux
A LAMP stack is a popular software bundle consisting of Linux, Apache, MySQL, and PHP, used for hosting and deploying web applications.
How to Set Up and Use SSH Key Authentication on Linux
Secure Shell (SSH) is a widely used protocol for secure remote access and management of Linux servers.
How to Create and Manage Cron Jobs on Linux
Cron jobs are a feature on Linux that enables users to automate repetitive tasks by scheduling scripts or commands to run at specific intervals.