Debian 9+ - Take control over DNS using dnsmasq

The following will make it possible to control what domains that can be accessed on a local machine by using a local DNS to filter requests.

Install dnsmasq:

apt-get install dnsmasq

Edit /etc/dnsmasq.d/whatever.conf

# block all sites
# let these through

The first line sends all unknown requests to localhost, the second two lines passes requests through.

Note that you do not need to enter subdomains, will work for both and

Restart dnsmasq to make it re-read settings:

service dnsmasq restart

Disable Network Manager interference with /etc/resolv.conf:

echo -e "[main]\ndns=none" > /etc/NetworkManager/conf.d/no-dns.conf
systemctl restart NetworkManager.service

Edit /etc/resolv.conf, to contain this:



This is a personal note. Last updated: 2018-05-18 22:25:12.


Don't forget to pay my friend a visit too. Joakim