[DNSMASQ][ADBLOCK] Block advertising on your whole network! D | LinuxCheatSheet
[DNSMASQ][ADBLOCK] Block advertising on your whole network!
Dnsmasq is a local DNS caching server that can run on your computer. It's a popular software and some Linux distributions install it by default to cache DNS queries. But it can do a lot more! For example it can be used to block advertising on your computer or even on your whole network. Let's start from this example configuration file: ~]# cat /tmp/dnsmasq.conf server=208.67.222.222 interface=lo listen-address=127.0.0.1 bind-interfaces conf-file=/etc/adblock.conf And /etc/adblock.conf contain the result of curl -kL "https://is.gd/UadtgE" > /etc/adblock.conf URL was shortened to fit on a mobile phone screen and it points to pgl.yoyo.org a popular ad blocking service. It contains entries like address=/doubleclick.com/127.0.0.1 that Dnsmasq use to fake the resolution of doubleclick.com and other advertising domains redirecting them to 127.0.0.1. Now start dnsmasq with systemctl restart dnsmasq if you are using a systemd based distro, or with dnsmasq -C /etc/dnsmasq.conf if you want to start it manually for test, and point your resolv.conf to ~]# cat /etc/resolv.conf nameserver 127.0.0.1 Now try to load your favorite bloated web site full of advertising and voilà! You should now have cleaned it up without even using a browser plugins. And if you do it on a central DNS server in your network for example your openwrt router on another server distributed as an option by your DHCP you can even protect your whole network from advertising, including mobile phones attached to it! (Remember to change listen-address in dnsmasq.conf with your local network interface IP in that case).
If you like it please share the channel with your friends: http://t.me/linuxcheatsheet Bye! G.
This channel is dedicated to broadcast linux suggestions, tricks on the command line, and black magic done with the shell. It is inspired to the (now closed) portico.org web site. The channel post wil...