====== Hosts File ====== See also a **better way**: **[[internet:security:pihole|Pi-Hole DNS Sinkhole and Add Blocker]]** The /etc/hosts file contains name resolution info that overrides DNS. You might add entries in the /etc/hosts file that is not in DNS. Here we use the /etc/hosts file as an ad filter. ===== Configuring ===== ==== winhelp2002 ==== Here is a public hosts file that we will use as a starting point: wget http://www.mvps.org/winhelp2002/hosts.txt vim hosts.txt Remove all lines before ''# [Start of entries generated by MVPS HOSTS]'' and append the rest to your own ''/etc/hosts'' file...or continue on to add the second list. ==== yoyo.org ==== Here we download another list and concatenate it with the previously downloaded list of adservers and your existing ''/etc/hosts'' file: wget -O hosts "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext" sed -i 's/127.0.0.1/0.0.0.0/g' hosts cat hosts >> hosts.txt vim hosts.txt # Set to unix file format :set ff=unix # Strip out DOS carriage returns - enter Ctrl-v Ctrl-m to input the ''^M'' :%s/^M//g # Strip all blank lines and comment lines :g/\v^(#|$)/d # Sort and remove duplicate lines :sort u cat hosts.txt >> /etc/hosts ===== SME Server ===== http://wiki.contribs.org/Block_Adware_Sites Here we use both adserver lists together: wget http://www.mvps.org/winhelp2002/hosts.txt mv hosts.txt /etc/e-smith/templates/etc/hosts/30hosts vim /etc/e-smith/templates/etc/hosts/30hosts Remove all lines before "#start of lines added by WinHelp2002" and save. Now we add the contents of another list: wget -O hosts "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext" cat hosts >> /etc/e-smith/templates/etc/hosts/30hosts expand-template /etc/hosts