User Tools

Site Tools


internet:security:hosts_file

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
internet:security:hosts_file [2012/04/17 14:54]
gcooper
internet:security:hosts_file [2019/04/23 10:14]
gcooper
Line 1: Line 1:
 ====== Hosts File ====== ====== 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. 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.
Line 17: Line 19:
 </file> </file>
  
-To use just this one list of adservers, remove all lines before "#start of lines added by WinHelp2002" and append the rest to your own /etc/hosts file...or continue on to add the second list.+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 ==== ==== yoyo.org ====
  
-Here we download another list and concatenate it with the previously downloaded list of adservers:+Here we download another list and concatenate it with the previously downloaded list of adservers and your existing ''/etc/hosts'' file:
  
 <file> <file>
 wget -O hosts "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext" 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
 +</file>
 +
 +<file>
 +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 >> /etc/hosts 
 cat hosts.txt >> /etc/hosts cat hosts.txt >> /etc/hosts
 </file> </file>
internet/security/hosts_file.txt · Last modified: 2019/04/23 10:14 by gcooper