Questo è uno script da poter installare sulla propria macchina server, per autogenerare (con un bel cron) file host da poter poi scaricare con uno script impostato nel vostro router.
Questo per avere file host sempre aggiornati.
#!/bin/bash rm -rf /opt/ads/* # Perform work in temporary files temphosts1=$(mktemp) # Obtain various hosts files and merge into one wget -qO - https://winhelp2002.mvps.org/hosts.txt >> $temphosts1 wget -qO - https://hosts-file.net/ad_servers.asp >> $temphosts1 wget -qO - https://someonewhocares.org/hosts/hosts >> $temphosts1 wget -qO - "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" >> $temphosts1 wget -qO - https://adaway.org/hosts.txt >> $temphosts1 #wget -qO - https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts >> $temphosts1 wget -qO - https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts >> $temphosts1 # Do some work on the file: # 1. Remove MS-DOS carriage returns # 4. Replace 127.0.0.1 with 0.0.0.0 because then we don't have to wait for the resolver to fail # 2. Delete all lines that don't begin with 0.0.0.0 # 5. Scrunch extraneous spaces separating address from name into a single tab # 6. Delete any comments on lines # 7. Clean up leftover trailing blanks # Pass all this through sort with the unique flag to remove duplicates and save the result sed -e 's/\r//' -e 's/127.0.0.1/0.0.0.0/' -e '/^0.0.0.0/!d' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < $temphosts1 | sort -u > /opt/ads/hosts #remove the first line sed -i -e "1d" /opt/ads/hosts L=$(wc -l /opt/ads/hosts | awk '{ print $1 }') NOW="#$L hosts $(date +"%d/%m/%Y %H:%M:%S")" sed -i "1 i\\$NOW" /opt/ads/hosts rm /var/www/auto/hosts.txt ln /opt/ads/hosts /var/www/auto/hosts.txt exit 0