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
spam [2014/03/14 14:31]
zagi
spam [2016/08/05 09:00] (current)
zagi
Line 14: Line 14:
    
 # Perform work in temporary files # Perform work in temporary files
-temphosts1="/opt/updateHF1.txt+temphosts1="/tmp/temphosts1.$$
-temphosts2="/opt/updateHF2.txt+temphosts2="/tmp/temphosts2.$$
-temphosts3="/opt/updateHF3.txt+temphosts3="/tmp/temphosts3.$$
-temphosts4="/opt/updateHF4.txt"+temphosts4="/tmp/temphosts4.$$"
    
 # Obtain various hosts files and merge into one # Obtain various hosts files and merge into one
Line 23: Line 23:
 wget -nv -O - http://winhelp2002.mvps.org/hosts.txt > $temphosts1 wget -nv -O - http://winhelp2002.mvps.org/hosts.txt > $temphosts1
 wget -nv -O - http://hosts-file.net/ad_servers.asp >> $temphosts1 wget -nv -O - http://hosts-file.net/ad_servers.asp >> $temphosts1
-wget -nv -O - http://someonewhocares.org/hosts/hosts >> $temphosts1+#wget -nv -O - http://someonewhocares.org/hosts/hosts >> $temphosts1 
 +wget -nv -O - http://someonewhocares.org/hosts/ipv6/hosts >> $temphosts1 
 +wget -nv -O - http://www.malwaredomainlist.com/hostslist/hosts.txt >> $temphosts1
 wget -nv -O - "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" >> $temphosts1 wget -nv -O - "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" >> $temphosts1
    
 # Do some work on the file: # Do some work on the file:
 # 1. Remove MS-DOS carriage returns # 1. Remove MS-DOS carriage returns
-# 2. Delete all lines that don't begin with 127.0.0.1 or 0.0.0.0 +# 2. Delete all lines that don't begin with 127.0.0.1 or 0.0.0.0 or ::1 
-# 3. Delete any lines containing the word localhost because we'll obtain that from the original hosts file +# 3. make everything lowercase 
-4. Scrunch extraneous spaces separating address from name into a single tab +# 4. Delete any lines containing the word localhost because we'll obtain that from the original hosts file 
-5. Delete any comments on lines +5. Replace 127.0.0.1 and  0.0.0.0 with ::1 {localhost on IPv6} 
-6. Clean up leftover trailing blanks+# 5. Scrunch extraneous spaces separating address from name into a single tab 
 +6. Delete any comments on lines 
 +7. Clean up leftover trailing blanks 
 +# 8. We whitelist hosts j.mp 
 +#
 # Pass all this through sort with the unique flag to remove duplicates and save the result # Pass all this through sort with the unique flag to remove duplicates and save the result
 echo "Parsing, cleaning, de-duplicating, sorting..." echo "Parsing, cleaning, de-duplicating, sorting..."
-sed -e 's/\r//' -e '/^127.0.0.1\|^0.0.0.0/!d' -e '/localhost/d'  -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < $temphosts1 | sort -u > $temphosts2 +
- +# IPv4 
 +#sed -e 's/\r//' -e '/^127.0.0.1\|^0.0.0.0\|^::1/!d -e 's/\(.*\)/\L\1/' -e '/localhost/d'  -e 's/127.0.0.1/0.0.0.0/' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < $temphosts1 | sort -u > $temphosts2 
 +
 +# IPv6 ready 
 +sed -e 's/\r//' -e '/^127.0.0.1\|^0.0.0.0\|^::1/!d' -e 's/\(.*\)/\L\1/' -e '/localhost/d' -e 's/127.0.0.1/::1/' -e 's/0.0.0.0/::1/' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < $temphosts1 | sort -u | grep -v $'\tj\.mp' > $temphosts2 
 # Combine system hosts with adblocks # Combine system hosts with adblocks
 echo Merging with original system hosts... echo Merging with original system hosts...
-echo -e "\n# Ad blocking hosts generated "`date` > $temphosts4+echo -e "# Windows HOSTS file should NOT be over 135K!\n# Ad blocking hosts generated "`date` > $temphosts4
 cat /etc/hosts.bak $temphosts4 $temphosts2 > $temphosts3 cat /etc/hosts.bak $temphosts4 $temphosts2 > $temphosts3
 sudo cp $temphosts3 /etc/hosts sudo cp $temphosts3 /etc/hosts
Line 51: Line 62:
 echo " sudo cp /etc/hosts.bak /etc/hosts" echo " sudo cp /etc/hosts.bak /etc/hosts"
 echo "so don't delete that file! (It's saved read-only for your protection.)" echo "so don't delete that file! (It's saved read-only for your protection.)"
 +
 +# *buntu style
 +/etc/init.d/network-manager  restart
 +
  
 </code> </code>
Line 56: Line 71:
 original (with bugs) @ http://www.deepthought.ws/linux/bash-script-hosts-file-ad-blocker/ original (with bugs) @ http://www.deepthought.ws/linux/bash-script-hosts-file-ad-blocker/
  
 +
 +how to use this in Ubuntu >>> https://tnt.aufbix.org/linux/ubuntu#optimize_dnsmasq_in_networkmanager
 ====== Fighting SPAM ====== ====== Fighting SPAM ======
  
spam.1394803878.txt.gz · Last modified: 2014/03/14 14:31 by zagi
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready