Giter Site home page Giter Site logo

ddwrt-adblocker's Introduction

ddwrt-adblocker

Blocks ads on router level using DD-WRT

based on discussions found on this forum thread: https://www.dd-wrt.com/forum/viewtopic.php?t=313987

Why this?

The simple answer: I have a cheap TP-Link TL-WR841ND router with no jffs, no USB port and limited (volatile) storage. This method:

  • works even after rebooting
  • keeps an up-to-date block list
  • has limited overhead
  • works on my cheap router

Other alternatives are the pixelserv method and using jffs to store the host list.

Usage

  1. Copy the startup code below to your Administration -> Commands and Save Startup. This will create a custom script to download a blacklist and add the domains to the dnsmasq.

  2. In Services -> Services -> Enable DNSMasq

  3. In Setup -> Basic Setup -> Enable Forced DNS Redirection

  4. To enable weekly updates, in Administration -> Management -> Cron -> Additional Cron Jobs add:

    0 11 * * 3 root /tmp/custom.sh

Startup code

# wait for the rest of the services to startup
sleep 20 

# Create script to download blacklist
echo '#!/bin/sh

logger Starting blockads scripts

# clean up old list
rm /tmp/adhosts

# get new list
wget -qO- http://sbc.io/hosts/hosts | grep "^0.0.0.0" > /tmp/adhosts;
 
# restart service
killall dnsmasq
dnsmasq -u root -g root --conf-file=/tmp/dnsmasq.conf

logger Finished executing blockads script' >> /tmp/custom.sh;

# add executable right 
chmod +x /tmp/custom.sh

# add blacklist to dnsmasq
grep "addn-hosts=/tmp/adhosts" /tmp/dnsmasq.conf || echo "addn-hosts=/tmp/adhosts" >> /tmp/dnsmasq.conf;

# execute script
/tmp/custom.sh

Notes

  • Tested with Firmware: DD-WRT v3.0-r45767 std (02/17/21) on a TP-Link TL-WR841ND v10
  • The script print to Syslog. Enable it in Services -> Syslog to see if the scripts started. Alternatively Telnet into the router and check if /tmp/custom.sh exists.

ddwrt-adblocker's People

Contributors

anielshri avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.