Home How To's block adservers (linux, fight advertising)

block adservers (linux, fight advertising)

block adservers (linux, fight advertising)

We find currently a totally out-of-control world of advertising and spam. Advertising and spam generating a whopping ~75% of all internet traffic. It's time, to take control back.

A good working sample:

#Before you begin, you should copy once your good working /etc/hosts to /etc/hosts00 manually!

$ cp /etc/hosts /etc/hosts00

#START SCRIPT

#downloading a maintained list of ad servers added to a a hosts file
$ wget -O /tmp/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts;
#blacklisted servers will be white listed, as we need it
$ grep -v "analytics.google.com" /tmp/hosts > temp && mv temp /tmp/hosts;
$ grep -v "googletagmanager" /tmp/hosts > temp && mv temp /tmp/hosts;
$ grep -v "googletagservices.com" /tmp/hosts > temp && mv temp /tmp/hosts;
#filtering for all lines starting with 0.0.0.0, that is all, what we want
$ sed -n '/^0.0.0.0/p' /tmp/hosts > temp && mv temp /tmp/hosts;
#sorting the banned entries, in case, we need some more to white list
$ sort /tmp/hosts > temp && mv temp /tmp/hosts;
#overwriting the current /etc/hosts with /etc/hosts00 and adding the filterd and sorted content
$ cat /etc/hosts00 /tmp/hosts > /etc/hosts;
# cleaning up
$ rm -f /tmp/hosts temp

Finally create a cronjob as root and set it to run maybe once a week

It has been read 188 times

IT Bizz.Net Tags:

#univention #univention ucs #univention corporate server ucs #univention vietnam #univention partner vietnam #vietnam open source #foss #devops #data science #security #network security #network security vietnam #open source