If you’re having trouble accessing certain websites or services, it might be because your DNS servers are not configured correctly. To change your DNS server on Linux, follow these steps:
- Open a terminal window and type the following command: sudo nano /etc/resolv.conf
- Add the following line to the file: nameserver 8.8.8.8
- Save the file and close it by pressing Ctrl+X then Y then Enter. Now that your DNS server has been changed, you’ll need to restart your computer’s network service for the changes to take effect: sudo service network restart ..
Whenever you try to connect to a website, slow DNS servers can cause delays. You might see unexpected websites if your DNS servers are set incorrectly. DNS servers can also be configured to prevent certain websites from being seen by your internet service provider, the government, or another organization. ..
Steps to Change DNS Server on Linux
Type the following command and press Enter: sudo apt-get update Type the following command and press Enter: sudo apt-get upgrade sudo apt-get update sudo apt-get upgrade ..
su - This will give you full access to the system as the root user. ..
- type: sudo passwd
- type: newgrp admin
- type: su -
- type: exit ..
The text editor opens. Type in the following lines: When the text editor opens, I type in the following lines. ..
Save the file as “myfile.txt”
Final Words
If you’re using a Linux-based operating system, like Ubuntu or Debian, and want to change your DNS server, here’s how:
- Open a terminal window by pressing the “Ctrl+Alt+T” key combination on your keyboard. This will open a command prompt window.
- Type the following command to get the current list of active DNS servers on your computer: sudo ip addr show dev eth0 | grep dnsmasq
- If you want to use a different DNS server, type the following command to add it to the list of active DNS servers: sudo ip addr add 192.168.1.1/24 dev eth0
- To make the changes take effect, type the following command: sudo ip link set dnsmasq up That’s it! You’ve successfully changed your DNS server on Linux! ..