You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
7.7 KiB

  1. # adblock script for openwrt
  2. ## Description
  3. A lot of people already use adblocker plugins within their desktop browsers,
  4. but what if you are using your (smart) phone, tablet, watch or any other wlan gadget...
  5. ...getting rid of annoying ads, trackers and other abuse sites (like facebook ;-) is simple: block them with your router.
  6. When the dns server on your router receives dns requests, you’ll sort out queries that ask for the [A] resource records of ad servers
  7. and return the local ip address of your router and the internal web server delivers a transparent pixel instead.
  8. ## Main Features
  9. * support of the following domain blacklist sites (free for private usage, for commercial use please check their individual licenses):
  10. * [pgl.yoyo.org](http://pgl.yoyo.org/adservers), approx. 2.500 entries
  11. * [malwaredomains.com](http://malwaredomains.com), approx. 16.000 entries
  12. * [zeustracker.abuse.ch](https://zeustracker.abuse.ch), currently down
  13. * [feodotracker.abuse.ch](https://feodotracker.abuse.ch), approx. 10 entries
  14. * [palevotracker.abuse.ch](https://palevotracker.abuse.ch), approx. 10 entries
  15. * [dshield.org](http://dshield.org), approx. 4.500 entries
  16. * [shallalist.de](http://www.shallalist.de) (tested with the categories "adv" "costtraps" "downloads" "spyware" "tracker" "warez"), approx. 37.000 entries
  17. * [spam404.com](http://www.spam404.com), approx. 5.000 entries
  18. * [winhelp2002.mvps.org](http://winhelp2002.mvps.org), approx. 15.000 entries
  19. * blocklist parsing by fast & flexible regex rulesets
  20. * additional white- and blacklist support for manual overrides
  21. * separate dynamic adblock network interface
  22. * separate dynamic uhttpd instance as pixel server
  23. * optional: quality checks and a powerful backup/restore handling to ensure a reliable dnsmasq service
  24. * optional: adblock updates only on pre-defined wan interfaces (useful for (mobile) multiwan setups)
  25. * optional: domain query logging as a background service to easily identify free and already blocked domains
  26. * optional: ntp time sync
  27. * optional: status & error logging (req. ntp time sync)
  28. ## Prerequisites
  29. * [openwrt](https://openwrt.org) (tested only with trunk > r47025), CC should also work
  30. * additional software packages:
  31. * curl
  32. * wget (due to an openwrt bug still needed for certain https requests - see ticket #19621)
  33. * optional: busybox find with *-mtime* support for logfile housekeeping (enabled by default with r47362, will be disabled if not found)
  34. * optional: coreutils-sort for reliable sort results, even on low memory systems
  35. * recommended: add an usb stick or any other storage device to supersize your /tmp directory with a swap partition (see [openwrt wiki](https://wiki.openwrt.org/doc/uci/fstab))
  36. * the above dependencies and requirements will be checked during package installation & script startup, please check console output or *logread -e "adblock"* for errors
  37. ## Usage
  38. * select & install adblock package (*opkg install adblock*)
  39. * configure /etc/config/adblock to your needs, see additional comments in *adblock.conf.sample*
  40. * at least configure the ip address of the local adblock interface/uhttpd instance, needs to be a different subnet from the normal LAN
  41. * by default openwrts main uhttpd instance is bind to all ports of your router. For a working adblock setup you have to bind uhttpd to the standard LAN port only, please change listen_http accordingly
  42. * start /usr/bin/adblock-update.sh and check console output or *logread -e "adblock"* for errors
  43. ## Distributed samples
  44. * all sample configuration files stored in */etc/adblock/samples*
  45. * to enable/disable additional domain query logging set the dnsmasq option *logqueries* accordingly, see *dhcp.config.sample*
  46. * to bind uhttpd to standard LAN port only, see *uhttpd.config.sample*
  47. * for script autostart by rc.local and /tmp resizing on the fly see *rc.local.sample*
  48. * for scheduled call of *adblock-update.sh* see *root.crontab.sample*
  49. * to redirect/force all dns queries to your router see *firwall.user.sample*
  50. * for further dnsmasq tweaks see *dnsmasq.conf.sample*
  51. ## Examples
  52. stdout excerpt for successful adblock run:
  53. root@pi2wrt:~# /usr/bin/adblock-update.sh
  54. adblock[17771] info : domain adblock processing started (0.21.0)
  55. adblock[17771] info : get wan/update interface (wlan1), after 0 loops
  56. adblock[17771] info : get ntp time sync (0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org), after 0 loops
  57. adblock[17771] info : shallalist archive download finished
  58. adblock[17771] info : shallalist archive extraction finished
  59. adblock[17771] info : shallalist (pre-)processing finished (adv costtraps downloads spyware tracker warez)
  60. adblock[17771] info : source download finished (http://pgl.yoyo.org/adservers/serverlist.php?hostformat=one-line&showintro=0&mimetype=plaintext, 2426 entries)
  61. adblock[17771] info : source download finished (http://mirror1.malwaredomains.com/files/justdomains, 15275 entries)
  62. adblock[17771] info : source download finished (https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist, 3 entries)
  63. adblock[17771] info : source download finished (https://feodotracker.abuse.ch/blocklist/?download=domainblocklist, 0 entries)
  64. adblock[17771] info : source download finished (https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist, 11 entries)
  65. adblock[17771] info : source download finished (http://www.dshield.org/feeds/suspiciousdomains_Low.txt, 4542 entries)
  66. adblock[17771] info : source download finished (http://spam404bl.com/spam404scamlist.txt, 5193 entries)
  67. adblock[17771] info : source download finished (http://winhelp2002.mvps.org/hosts.txt, 13852 entries)
  68. adblock[17771] info : source download finished (file:////tmp/tmp.emlDeH/shallalist.txt, 36961 entries)
  69. adblock[17771] info : source download finished (file:///etc/adblock/adblock.blacklist, 1 entries)
  70. adblock[17771] info : new adblock list with 73090 domains loaded, backup generated
  71. adblock[17771] info : domain adblock processing finished (0.21.0)
  72. generated domain blocklist for dnsmasq:
  73. address=/0-29.com/192.168.2.1
  74. address=/0-2u.com/192.168.2.1
  75. address=/0.r.msn.com/192.168.2.1
  76. address=/00.devoid.us/192.168.2.1
  77. address=/000007.ru/192.168.2.1
  78. [...]
  79. address=/zzz.cn/192.168.2.1
  80. address=/zzzjsh.com/192.168.2.1
  81. ####################################################
  82. # last adblock list update: 20.11.2015 - 18:00:02
  83. # adblock-update.sh (0.21.0) - 73087 ad/abuse domains blocked
  84. # domain blacklist sources:
  85. # http://pgl.yoyo.org/adservers/serverlist.php?hostformat=one-line&showintro=0&mimetype=plaintext
  86. # http://mirror1.malwaredomains.com/files/justdomains
  87. # https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
  88. # https://feodotracker.abuse.ch/blocklist/?download=domainblocklist
  89. # https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist
  90. # http://www.dshield.org/feeds/suspiciousdomains_Low.txt
  91. # http://spam404bl.com/spam404scamlist.txt
  92. # http://winhelp2002.mvps.org/hosts.txt
  93. # file:////tmp/tmp.CLBLNF/shallalist.txt
  94. # file:///etc/adblock/adblock.blacklist
  95. #####
  96. # /etc/adblock/adblock.whitelist
  97. ####################################################
  98. domain query log excerpt:
  99. query[A] www.seenby.de from fe80::6257:18ff:fe6b:4667
  100. query[A] tarifrechner.heise.de from 192.168.1.131
  101. query[A] www.mittelstandswiki.de from fe80::6257:18ff:fe6b:4667
  102. query[A] ad.doubleclick.net from 192.168.1.131
  103. ad.doubleclick.net is 192.168.2.1
  104. The first three queries are OK (not blocked), the last one has been blocked and answered by local dnsmasq instance.
  105. Have fun!
  106. Dirk