This is an old revision of the document!
Blocking Ads
Nobody like ads, let's be real. Also, ads are a security risk since they can deliver malware or force the users to tap on stuff they shouldn't. Luckly, it's easy to fix this by setting up a network-wide ad blocking.
I am using DNSMASQ on my network, and you should do the same, so that you are in control of your ad blocking stuff.
Install it:
> emerge dnsmasq
and edit your config file /etc/dnsmasq.conf to contain the following:
addn-hosts=/etc/adblock.hosts
The more complex way is to populate that file, which is a standard hosts file, so in the format:
0.0.0.0 ads.google.com
where the trick is mapping all ads servers to invalid addresses like 0.0.0.0.
There are some good adblock lists here:
And this command will download and properly format it:
curl "https://raw.githubusercontent.com/Ewpratten/youtube_ad_blocklist/master/blocklist.txt" "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" 2> /dev/null | awk -F' ' '!a[$NF]++ {gsub(/^/,"0.0.0.0 ",$NF) ; print $NF ; gsub(/^(127|0)\.0\.0\.(0|1)/,"::1",$NF) ; print $NF}' > /etc/adblock.hosts
All you need to do now is add to crontab for automatic updates, add a line like:
0 4 * * * root curl "https://raw.githubusercontent.com/Ewpratten/youtube_ad_blocklist/master/blocklist.txt" "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" 2> /dev/null | awk -F' ' '!a[$NF]++ {gsub(/^/,"0.0.0.0 ",$NF) ; print $NF ; gsub(/^0\.0\.0\.0/,"::1",$NF) ; print $NF}' > /etc/dnsmasq/adblock.hosts && rc-service dnsmasq restart > /dev/null
to your
> crontab -e