DNSMASQ host files can be specified using the following custom configuration:
addn-hosts=/etc/fusion/custom
Here is a script that can be run nightly via crontab to download some host files that can be cherry picked to block name resolution to certain categories of web sites:
#!/bin/bash # startubl.sh A script to download host files for DNSMASQ date > /var/log/updateblacklist/cl-`date +%d%H`.run /usr/bin/curl -vs https://blocklistproject.github.io/Lists/abuse.txt -o /etc/fusion/abuse sed -i '/^ *#/d; /^ *$/d' /etc/fusion/abuse /usr/bin/curl -vs https://blocklistproject.github.io/Lists/ads.txt -o /etc/fusion/ads sed -i '/^ *#/d; /^ *$/d' /etc/fusion/ads /usr/bin/curl -vs https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt -o /etc/fusion/ads_1 sed -i '/^ *#/d; /^ *$/d' /etc/fusion/ads_1 /usr/bin/curl -vs https://v.firebog.net/hosts/AdguardDNS.txt -o /etc/fusion/ads_2 sed -i '/^ *#/d; /^ *$/d' /etc/fusion/ads_2 sed -i 's/^/0.0.0.0\t/' /etc/fusion/ads_2 /usr/bin/curl -vs https://block.energized.pro/blu/formats/hosts.txt -o /etc/fusion/blu sed -i '/^[ \t]*#/d; /^ *$/d' /etc/fusion/blu sed -i '/googleadservices/d' /etc/fusion/blu /usr/bin/curl -vs https://blocklistproject.github.io/Lists/crypto.txt -o /etc/fusion/crypto sed -i '/^ *#/d; /^ *$/d' /etc/fusion/crypto /usr/bin/curl -vs https://www.github.developerdan.com/hosts/lists/dating-services-extended.txt -o /etc/fusion/dating sed -i '/^ *#/d; /^ *$/d' /etc/fusion/dating /usr/bin/curl -vs https://blocklistproject.github.io/Lists/drugs.txt -o /etc/fusion/drugs sed -i '/^ *#/d; /^ *$/d' /etc/fusion/drugs /usr/bin/curl -vs https://blocklistproject.github.io/Lists/facebook.txt -o /etc/fusion/facebook sed -i '/^ *#/d; /^ *$/d' /etc/fusion/facebook /usr/bin/curl -vs https://www.github.developerdan.com/hosts/lists/facebook-extended.txt -o /etc/fusion/facebook_1 sed -i '/^ *#/d; /^ *$/d' /etc/fusion/facebook_1 /usr/bin/curl -vs https://blocklistproject.github.io/Lists/fraud.txt -o /etc/fusion/fraud sed -i '/^ *#/d; /^ *$/d' /etc/fusion/fraud /usr/bin/curl -vs https://blocklistproject.github.io/Lists/gambling.txt -o /etc/fusion/gambling sed -i '/^ *#/d; /^ *$/d' /etc/fusion/gambling /usr/bin/curl -vs https://www.github.developerdan.com/hosts/lists/hate-and-junk-extended.txt -o /etc/fusion/junk sed -i '/^ *#/d; /^ *$/d' /etc/fusion/junk /usr/bin/curl -vs https://blocklistproject.github.io/Lists/malware.txt -o /etc/fusion/malware sed -i '/^ *#/d; /^ *$/d' /etc/fusion/malware /usr/bin/curl -vs https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt -o /etc/fusion/mining sed -i '/^ *#/d; /^ *$/d' /etc/fusion/mining sed -i 's/^/0.0.0.0\t/' /etc/fusion/mining /usr/bin/curl -vs https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt -o /etc/fusion/notracking sed -i '/^ *#/d; /^ *$/d' /etc/fusion/notracking /usr/bin/curl -vs https://dbl.oisd.nl/nsfw/ -o /etc/fusion/nsfw sed -i '/^ *#/d; /^ *$/d' /etc/fusion/nsfw sed -i 's/^/0.0.0.0\t/' /etc/fusion/nsfw /usr/bin/curl -vs https://dbl.oisd.nl/ -o /etc/fusion/oisd sed -i '/^ *#/d; /^ *$/d' /etc/fusion/oisd sed -i 's/^/0.0.0.0\t/' /etc/fusion/oisd /usr/bin/curl -vs https://blocklistproject.github.io/Lists/phishing.txt -o /etc/fusion/phishing sed -i '/^ *#/d; /^ *$/d' /etc/fusion/phising /usr/bin/curl -vs https://blocklistproject.github.io/Lists/piracy.txt -o /etc/fusion/piracy sed -i '/^ *#/d; /^ *$/d' /etc/fusion/piracy /usr/bin/curl -vs https://block.energized.pro/porn/formats/hosts -o /etc/fusion/porn sed -i '/^[ \t]*#/d; /^ *$/d' /etc/fusion/porn sed -i '/googleadservices/d' /etc/fusion/porn /usr/bin/curl -vs https://blocklistproject.github.io/Lists/porn.txt -o /etc/fusion/porn_1 sed -i '/^ *#/d; /^ *$/d' /etc/fusion/porn_1 /usr/bin/curl -vs https://blocklistproject.github.io/Lists/ransomware.txt -o /etc/fusion/ransomware sed -i '/^ *#/d; /^ *$/d' /etc/fusion/ransomware /usr/bin/curl -vs https://blocklistproject.github.io/Lists/redirect.txt -o /etc/fusion/redirect sed -i '/^ *#/d; /^ *$/d' /etc/fusion/redirect /usr/bin/curl -vs https://blocklistproject.github.io/Lists/scam.txt -o /etc/fusion/scam sed -i '/^ *#/d; /^ *$/d' /etc/fusion/scam /usr/bin/curl -vs https://block.energized.pro/spark/formats/hosts.txt -o /etc/fusion/spark sed -i '/^[ \t]*#/d; /^ *$/d' /etc/fusion/spark sed -i '/googleadservices/d' /etc/fusion/spark /usr/bin/curl -vs https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts -o /etc/fusion/stevenblack | sed -i '/^ *#/d; /^ *$/d' /etc/fusion/stevenblack /usr/bin/curl -vs https://blocklistproject.github.io/Lists/tiktok.txt -o /etc/fusion/tiktok sed -i '/^ *#/d; /^ *$/d' /etc/fusion/tiktok /usr/bin/curl -vs https://blocklistproject.github.io/Lists/torrent.txt -o /etc/fusion/torrent sed -i '/^ *#/d; /^ *$/d' /etc/fusion/torrent /usr/bin/curl -vs https://blocklistproject.github.io/Lists/tracking.txt -o /etc/fusion/tracking sed -i '/^ *#/d; /^ *$/d' /etc/fusion/tracking /usr/bin/curl -vs https://hosts.ubuntu101.co.za/hosts -o /etc/fusion/ultimate sed -i '/^[ \t]*#/d; /^ *$/d' /etc/fusion/ultimate sed -i '/google\|dartsearch\|hubspot/d' /etc/fusion/ultimate # sed -i '/dartsearch/d' /etc/fusion/ultimate # sed -i '/hubspot/d' /etc/fusion/ultimate /usr/bin/curl -vs https://blocklistproject.github.io/Lists/whatsapp.txt -o /etc/fusion/whatsapp sed -i '/^ *#/d; /^ *$/d' /etc/fusion/whatsapp # Restart DNSMASQ kill $(cat /var/run/bonding/dnsmasq.pid) date >> /var/log/updateblacklist/cl-`date +%d%H`.run
This article was originally published over on LinkedIn: Cherry picking DNSMASQ host files
Comments
Post a Comment