User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sailing:adblock [2024/01/09 09:41] willysailing:adblock [2024/02/22 09:48] (current) – removed willy
Line 1: Line 1:
-====== 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 [[https://thekelleys.org.uk/dnsmasq/doc.html|DNSMASQ]] on my network, and you should do the same, so that you are in control of your ad blocking stuff. 
- 
-Install it: 
-<code bash> 
- > emerge dnsmasq 
-</code> 
- 
-and edit your config file **/etc/dnsmasq.conf** to contain the following: 
-<code> 
-addn-hosts=/etc/adblock.hosts 
-</code> 
- 
-The more complex way is to populate that file, which is a standard //hosts// file, so in the format: 
-<code> 
-0.0.0.0 ads.google.com 
-</code> 
-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: 
-<code bash> 
-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 
-</code> 
- 
-All you need to do now is add to //crontab// for automatic updates, add a line like: 
-<code> 
-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 
-</code> 
- 
-to your 
-<code bash> 
- > crontab -e 
-</code> 
- 
- 
- 
  

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information