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.

151 lines
9.5 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 blocklist sources (free for private usage, for commercial use please check their individual licenses):
  10. * [pgl.yoyo.org](http://pgl.yoyo.org/adservers)
  11. * => weekly updates, approx. 2.500 entries (enabled by default)
  12. * [malwaredomains.com](http://malwaredomains.com)
  13. * => daily updates, approx. 16.000 entries
  14. * [zeustracker.abuse.ch](https://zeustracker.abuse.ch)
  15. * => daily updates, approx. 440 entries
  16. * [feodotracker.abuse.ch](https://feodotracker.abuse.ch)
  17. * => daily updates, approx. 0-10 entries
  18. * [palevotracker.abuse.ch](https://palevotracker.abuse.ch)
  19. * => daily updates, approx. 15 entries
  20. * [dshield.org](http://dshield.org)
  21. * => daily updates, approx. 4.500 entries
  22. * [shallalist.de](http://www.shallalist.de) (categories "adv" "costtraps" "spyware" "tracker" "warez" enabled by default)
  23. * => daily updates, approx. 32.000 entries (a short description of all shallalist categories can be found [online](http://www.shallalist.de/categories.html))
  24. * [spam404.com](http://www.spam404.com)
  25. * => infrequent updates, approx. 5.000 entries
  26. * [winhelp2002.mvps.org](http://winhelp2002.mvps.org)
  27. * => infrequent updates, approx. 15.000 entries
  28. * [adaway.org](https://adaway.org)
  29. * => infrequent updates, approx. 400 entries
  30. * [disconnect.me](https://disconnect.me)
  31. * => numerous updates on the same day, approx. 6.500 entries
  32. * each blocklist source will be updated and processed separately
  33. * timestamp check to download and process only updated blocklists
  34. * overall duplicate removal in separate blocklists (will be automatically disabled on low memory systems)
  35. * blocklist parsing by fast & flexible regex rulesets
  36. * additional white- and blacklist support for manual overrides
  37. * use of dynamic adblock network interface
  38. * use of dynamic uhttpd instance as pixel server
  39. * use of quality checks after adblocklist updates to ensure a reliable dnsmasq service
  40. * optional features (disabled by default):
  41. * powerful adblock list backup/restore handling
  42. * adblock updates only on pre-defined wan interfaces (useful for (mobile) multiwan setups)
  43. * domain query logging as a background service to easily identify free and already blocked domains (see example output below)
  44. * ntp time sync
  45. * status & error logging to separate file (req. ntp time sync)
  46. ## Prerequisites
  47. * [openwrt](https://openwrt.org) (tested only with trunk > r47025), CC should also work
  48. * additional software packages:
  49. * curl
  50. * wget (due to an openwrt bug still needed for certain https requests - see ticket #19621)
  51. * optional: busybox find with *-mtime* support for logfile housekeeping (enabled by default with r47362, will be disabled if not found)
  52. * the above dependencies and requirements will be checked during package installation & script startup, please check console output or *logread -e "adblock"* for errors
  53. ## Usage
  54. * select & install adblock package (*opkg install adblock*)
  55. * configure */etc/config/adblock* to your needs, see additional comments in *adblock.conf.sample*
  56. * at least configure the ip address of the local adblock interface/uhttpd instance, it needs to be a different subnet from the normal LAN
  57. * recommendation: there is no need to enable all blacklist sites at once, for normal use one to three lists should be sufficient
  58. * recommendation: to handle all blacklists at once add an usb stick or any other storage device to supersize your /tmp directory with a swap partition
  59. * => see [openwrt wiki](https://wiki.openwrt.org/doc/uci/fstab) for further details
  60. * add additional domain white- or blacklist entries, one domain per line (wildcards & regex are not allowed!), both lists are located in */etc/adblock*
  61. * by default openwrts main uhttpd instance is bind to all ports of your router,
  62. * for a working adblock setup you have to bind uhttpd to the standard LAN port only, please change listen_http accordingly
  63. * start /usr/bin/adblock-update.sh and check console output or *logread -e "adblock"* for errors
  64. ## Distributed samples
  65. * all sample configuration files stored in */etc/adblock/samples*
  66. * to enable/disable additional domain query logging set the dnsmasq option *logqueries* accordingly, see *dhcp.config.sample*
  67. * to bind uhttpd to standard LAN port only, see *uhttpd.config.sample*
  68. * for rc.local based autostart and /tmp resizing on the fly see *rc.local.sample*
  69. * for scheduled call of *adblock-update.sh* see *root.crontab.sample*
  70. * to redirect/force all dns queries to your router see *firwall.user.sample*
  71. * for further dnsmasq tweaks see *dnsmasq.conf.sample*
  72. ## Examples
  73. log of a full adblock run:
  74. adblock[1586] info : domain adblock processing started (0.40.0, r47670, 17.12.2015 10:50:09)
  75. adblock[1586] info : wan update check will be disabled
  76. adblock[1586] info : get ntp time sync (192.168.2.254), after 0 loops
  77. adblock[1586] info : created new dynamic/volatile network interface (adblock, 192.168.2.1)
  78. adblock[1586] info : created new dynamic/volatile uhttpd instance (adblock, 192.168.2.1)
  79. adblock[1586] info : shallalist (pre-)processing started ...
  80. adblock[1586] info : source download finished (http://pgl.yoyo.org/adservers/serverlist.php?hostformat=one-line&showintro=0&mimetype=plaintext, 2432 entries)
  81. adblock[1586] info : domain merging finished (yoyo)
  82. adblock[1586] info : source download finished (http://mirror1.malwaredomains.com/files/justdomains, 17368 entries)
  83. adblock[1586] info : domain merging finished (malware)
  84. adblock[1586] info : source download finished (https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist, 440 entries)
  85. adblock[1586] info : domain merging finished (zeus)
  86. adblock[1586] info : no online timestamp received, current date will be used (feodo)
  87. adblock[1586] info : source download finished (https://feodotracker.abuse.ch/blocklist/?download=domainblocklist, 0 entries)
  88. adblock[1586] info : empty domain input received (feodo)
  89. adblock[1586] info : no online timestamp received, current date will be used (palevo)
  90. adblock[1586] info : source download finished (https://palevotracker.abuse.ch/blocklists.php?download=domainblocklist, 16 entries)
  91. adblock[1586] info : domain merging finished (palevo)
  92. adblock[1586] info : source download finished (http://www.dshield.org/feeds/suspiciousdomains_Low.txt, 4542 entries)
  93. adblock[1586] info : domain merging finished (dshield)
  94. adblock[1586] info : source download finished (http://spam404bl.com/spam404scamlist.txt, 5193 entries)
  95. adblock[1586] info : domain merging finished (spam404)
  96. adblock[1586] info : source download finished (http://winhelp2002.mvps.org/hosts.txt, 13635 entries)
  97. adblock[1586] info : domain merging finished (winhelp)
  98. adblock[1586] info : source download finished (https://adaway.org/hosts.txt, 410 entries)
  99. adblock[1586] info : domain merging finished (adaway)
  100. adblock[1586] info : source download finished (https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt, 6343 entries)
  101. adblock[1586] info : domain merging finished (disconnect)
  102. adblock[1586] info : source download finished (file:////tmp/tmp.FIhIBh/shallalist.txt, 32458 entries)
  103. adblock[1586] info : domain merging finished (shalla)
  104. adblock[1586] info : source download finished (file:///etc/adblock/adblock.blacklist, 1 entries)
  105. adblock[1586] info : domain merging finished (blacklist)
  106. adblock[1586] info : remove duplicates in separate adblocklists ...
  107. adblock[1586] info : adblocklists with overall 71552 domains loaded, new backups generated
  108. adblock[1586] info : new domain query log background process started (pid: 2416)
  109. adblock[1586] info : domain adblock processing finished (0.40.0, r47670, 17.12.2015 10:52:47)
  110. domain blocklist for dnsmasq (disconnect.me after overall duplicate removal):
  111. address=/0000mps.webpreview.dsl.net/192.168.2.1
  112. address=/0001.2waky.com/192.168.2.1
  113. address=/001wen.com/192.168.2.1
  114. address=/002it.com/192.168.2.1
  115. address=/00game.net/192.168.2.1
  116. [...]
  117. address=/zzsgssxh.com/192.168.2.1
  118. address=/zzshw.net/192.168.2.1
  119. address=/zztxdown.com/192.168.2.1
  120. address=/zzxcws.com/192.168.2.1
  121. #------------------------------------------------------------------
  122. # adblock-update.sh (0.40.0) - 3710 ad/abuse domains blocked
  123. # source: https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt
  124. # last modified: Thu, 17 Dec 2015 09:21:17 GMT
  125. domain query log excerpt:
  126. query[A] www.seenby.de from fe80::6257:18ff:fe6b:4667
  127. query[A] tarifrechner.heise.de from 192.168.1.131
  128. query[A] www.mittelstandswiki.de from fe80::6257:18ff:fe6b:4667
  129. query[A] ad.doubleclick.net from 192.168.1.131
  130. ad.doubleclick.net is 192.168.2.1
  131. The first three queries are OK (not blocked), the last one has been blocked and answered by local dnsmasq instance.
  132. Have fun!
  133. Dirk