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
internet:security:hosts_file [2015/12/26 22:41]
gcooper
internet:security:hosts_file [2019/04/23 10:14] (current)
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 13: Line 15:
 <file> <file>
 wget http://www.mvps.org/winhelp2002/hosts.txt wget http://www.mvps.org/winhelp2002/hosts.txt
 +
 +vim hosts.txt
 </file> </file>
  
-To use just this one list of ad servers, 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.+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 ====
Line 24: Line 28:
 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 sed -i 's/127.0.0.1/0.0.0.0/g' hosts
-cat hosts >> /etc/hosts.txt+cat hosts >> hosts.txt
 </file> </file>
  
 +<file>
 vim 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 :%s/^M//g
  
 +# Strip all blank lines and comment lines
 +:g/\v^(#|$)/d
  
-:!: To strip out the DOS carriage returns, enter Ctrl-v Ctrl-m to input the ''^M''.+# Sort and remove duplicate lines 
 +:sort u
  
 cat hosts.txt >> /etc/hosts cat hosts.txt >> /etc/hosts
 +</file>
  
 ===== SME Server ===== ===== SME Server =====
internet/security/hosts_file.1451194872.txt.gz · Last modified: 2015/12/26 22:41 by gcooper