DNS or the Domain Name Server is a proof of your current Location. It is managed by your local ISP( Internet Service Provider). When your current DNS settings are misconfigured or you need to spoof it for some educational purpose, you should always know how to change the DNS of your local Linux Machine.
It is an easy and smooth process. First, you need to find your resolv.conf file. Follow this post to learn how to change your DNS step by step.
Update your configuration file
Most of the Linux distros have their resolv.conf file located in the /etc folder. You can simply find it at /etc/resolv.conf.
To open this file, use cat or less commands. They display the content of the file in your terminal
[boogieman@b00gi3m4n ~]$ cat /etc/resolv.conf # Generated by NetworkManager nameserver 177.xxx.xx.x nameserver 2403:xxx:xxxx:xxxx::xx [boogieman@b00gi3m4n ~]$
Of course, I have hidden my original DNS settings behind xx for security issues. As you can see there is a “# Generated by NetworkManager“. It means these files have been modified by your Network Manager in response to your local ISP.
Both of these lines starting with “nameserver” define a DNS server setting. Therefore these settings are automatically generated and the system does not know what to do with them until after it is connected to the internet and a domain.
There should be at least 1 DNS server setting available in the resolv.conf file. If there is no file available, you can create with nano or a similar editor. We will use nano to edit this file. REMEMBER, you need root privileges to update/edit this file.
[root@b00gi3m4n boogieman]# nano /etc/resolv.conf
# Generated by NetworkManager nameserver 177.xxx.xx.x nameserver 2403:xxx:xxxx:xxxx::xx
now you have to update this file. You can assign a minimum of 1 or a maximum of 3 nameservers for this setting. The system reads this file in ascending order. It means the nameserver setting mentioned on the top will be read by the system first. If this setting is incorrectly updated or is not available in the server location, the system will move to the set below it (#2)
List of the DNS servers
You can use any of these DNS servers for your resolv.conf file.
|DNS SERVER||DNS SETTING|
Choose any of these setting from the list and update your file like this
# Generated by NetworkManager nameserver 126.96.36.199 nameserver 188.8.131.52
Check out this screenshot of my current DNS settings below.
Make sure you do a Ping Check before visiting any website on the internet. You can also visit this website to check if your DNS is leaking.
[root@b00gi3m4n boogieman]# ping server99s.com PING server99s.com (184.108.40.206) 56(84) bytes of data. 64 bytes from 162-252-83-203.static.hvvc.us (220.127.116.11): icmp_seq=1 ttl=46 time=378 ms 64 bytes from 162-252-83-203.static.hvvc.us (18.104.22.168): icmp_seq=2 ttl=46 time=344 ms 64 bytes from 162-252-83-203.static.hvvc.us (22.214.171.124): icmp_seq=3 ttl=46 time=275 ms 64 bytes from 162-252-83-203.static.hvvc.us (126.96.36.199): icmp_seq=4 ttl=46 time=589 ms ^C --- server99s.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 274.897/396.287/588.912/117.220 ms
It is working perfectly for my case. Now you know how to change the DNS of your Linux machine. Tell me in the comments if you run into any problems. I’ll be happy to help.
This tutorial/guide teaches you how to change your DNS. It is for educational purposes only. Indulging in any illegal activity and misusing this without the written permission of the party is a criminal offense and we DO NOT promote any illegal activity. It is advised to use it only for educational/white hat purpose.
If you liked it found it informative, please do share it on your social media and with your friends. It helps us keep the blog running and so much more can be shared in lesser time. It only takes a click.