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:55]
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 26: 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> <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'' # Strip out DOS carriage returns - enter Ctrl-v Ctrl-m to input the ''^M''
Line 37: Line 42:
 # Strip all blank lines and comment lines # Strip all blank lines and comment lines
 :g/\v^(#|$)/d :g/\v^(#|$)/d
 +
 +# Sort and remove duplicate lines
 +:sort u
  
 cat hosts.txt >> /etc/hosts cat hosts.txt >> /etc/hosts
internet/security/hosts_file.1451195706.txt.gz · Last modified: 2015/12/26 22:55 by gcooper