Skip to content

Instantly share code, notes, and snippets.

@ptb
Last active February 24, 2017 14:08
Show Gist options
  • Save ptb/a1ade14ef616ccba2a0f to your computer and use it in GitHub Desktop.
Save ptb/a1ade14ef616ccba2a0f to your computer and use it in GitHub Desktop.
OpenWRT pixelserv, dnsmasq, ad block
#!/bin/sh
DNSSERVER=172.16.1.1
/usr/bin/wget -qO- http://mvps.org/winhelp2002/hosts.txt | /bin/grep -v -e localhost -e=feeds.feedburner.com | /bin/grep '^0.0.0.0' | /bin/sed "s/^0\.0\.0\.0/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-1
/usr/bin/wget -qO- http://www.malwaredomainlist.com/hostslist/hosts.txt | /bin/grep -v -e localhost | /bin/grep '^127.0.0.1' | /bin/sed "s/^127\.0\.0\.1/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-2
/usr/bin/wget -qO- http://hosts-file.net/ad_servers.txt | /bin/grep -v -e localhost | /bin/grep '^127.0.0.1' | /bin/sed "s/^127\.0\.0\.1/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-3
/usr/bin/wget -qO- http://adaway.org/hosts.txt | /bin/grep -v -e localhost | /bin/grep '^127.0.0.1' | /bin/sed "s/^127\.0\.0\.1/$DNSSERVER/" | /bin/sed 's/\s*#.*$//' | /bin/sed 's/.$//' > /etc/hosts.block-4
/bin/cat /etc/hosts.block-1 /etc/hosts.block-2 /etc/hosts.block-3 /etc/hosts.block-4 | /bin/sed 's/[ \s\t]+/\t/' | /usr/bin/sort -n | /usr/bin/uniq > /etc/hosts.block
/bin/rm /etc/hosts.block-1 /etc/hosts.block-2 /etc/hosts.block-3 /etc/hosts.block-4
#!/bin/sh
#/usr/bin/curl --location --silent http://mvps.org/winhelp2002/hosts.txt | /usr/bin/grep --invert-match --regexp=localhost --regexp=feeds.feedburner.com | /usr/bin/sed 's/.$//' | /usr/bin/iconv --from-code=ISO-8859-1 --to-code=UTF-8 | /usr/bin/grep '^0.0.0.0' > /private/etc/hosts.mvps
server = 8.8.4.4
server = 8.8.8.8
#
addn-hosts = /etc/hosts.block
#
# domain = ptb2.me, 172.16.8.1, 172.16.8.13
#
all-servers # send all queries to all available servers
bogus-nxdomain = 208.67.216.132 # disable "helpful" guide.opendns.com page
bogus-priv # non-routed IPs are answered with NXDOMAIN
domain-needed # do not forward queries for names without dots
keep-in-foreground # do not go into the background at startup
no-resolv # do not read /etc/resolv.conf
# http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
/usr/bin/wget -O /www/1.gif http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif
/usr/bin/wget -O /www/2.gif http://probablyprogramming.com/wp-content/uploads/2009/03/handtinywhite.gif
/usr/bin/wget -O /www/3.gif http://probablyprogramming.com/wp-content/uploads/2009/03/handtinyblack.gif
vi /etc/config/uhttpd
option error_page '/1.gif'
/etc/init.d/uhttpd restart
vi /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment