Dns

Set custom DNS servers on Linux with resolv.conf

resolv.conf is the configuration file for DNS resolvers for all Linux distributions, including Debian, Mint, Ubuntu, RedHat, CentOS, etc. Usually we change the DNS resolvers list by editing resolv.conf. However, depends on your dhcp client configuration, resolv.conf may be rewrite after reboot. Without deep Linux experience, setting customs DNS servers on Linux maybe time consuming. But one thing we can do is make /etc/resolv.conf immutable to other program after you changed it. This will be the easier setup with no side effects on system.

Change the DNS server

Below example we will set DNS resolver to 1.1.1.1. (1.1.1.1 is a privacy-first consumer DNS service provided by Cloudflare.)

sudo echo 'nameserver 1.1.1.1' > /etc/resolv.conf

Run the chattr +i command to sets the immutable filesystem attribute on resolv.conf, so it can't be modified any anyone else.

sudo chattr +i /etc/resolv.conf

Reboot your system and test if your change to DNS server succeed. You can test it via DNS leak test.

If you want to make change to resolv.conf again, you need to remove the attribute.

sudo chattr -i /etc/resolv.conf

Some free public DNS server list:

Google Public DNS
8.8.8.8 / 2001:4860:4860::8888
8.8.4.4 / 2001:4860:4860::8844

OpenDNS
208.67.222.222 / 2620:0:ccc::2
208.67.220.220 / 2620:0:ccd::2

Comodo Secure DNS
8.26.56.26
8.20.247.20

Norton ConnectSafe
199.85.126.10
199.85.127.10

Level 3:
209.244.0.3
209.244.0.4

Verisign Public DNS
64.6.64.6
64.6.65.6

DNS.WATCH
84.200.69.80
84.200.70.40
2001:1608:10:25::1c04:b12f
2001:1608:10:25::9249:d69b

AdGuard
Default
176.103.130.130
176.103.130.131
2a00:5a60::ad1:0ff
2a00:5a60::ad2:0ff

Family protection
176.103.130.132
176.103.130.134
2a00:5a60::bad1:0ff
2a00:5a60::bad2:0ff

Quad9
9.9.9.9
9.9.9.10
2620:fe::fe
2620:fe::10

Cloudflare DNS Resolver
1.1.1.1
1.0.0.1
2606:4700:4700::1111
2606:4700:4700::1001

CleanBrowsing
Family Filter
185.228.168.168
185.228.168.169
2a0d:2a00:1::
2a0d:2a00:2::

Leave a Reply

Your email address will not be published. Required fields are marked *