How to setup adblocker on OpenWrt router

In this quick guide we will see how to setup adblocker on OpenWrt router. I tested this on PandoraBox (OpenWrt based firmware for Xiaomi Mi3 router) and it works beautifully.

Installing necessary packages

We need to install some packages before setting up adblocker. First SSH into your router then execute the below commands (execute those commands one by one)

wget --no-check-certificate https://gist.githubusercontent.com/k4mrul/6d0e395e5a332c2a2c27756d0d3b4c51/raw/dba9996ff7a0cd5973fe5ef93dbb0909d49cc180/ssl-in-wget.sh
chmod +x ssl-in-wget.sh
sh ssl-in-wget.sh

Setting up adblocker

Execute those below commands to download my custom adblocker script into /etc directory. The script will block ads and porn sites. You can modify the script if you want

cd /etc
wget https://gist.githubusercontent.com/k4mrul/76e21ace2558e30be15b4727e28f461f/raw/2d6ef2b27f6022548c4e76b9308af15f51f8e6f2/adblock.sh
wget https://gist.github.com/k4mrul/76e21ace2558e30be15b4727e28f461f/raw/2d6ef2b27f6022548c4e76b9308af15f51f8e6f2/white.list

Now give proper permission to adblock.sh script and execute

chmod +x adblock.sh
sh adblock.sh

Done! If you need to add a website to whitelist, simply open /etc/white.list file and add your website. Then execute the below command.

sh adblock.sh

 

2 thoughts on “How to setup adblocker on OpenWrt router

  1. makima

    nice! thank you!

    1. Kamrul

      Glad it helped. Thanks for reading

Leave a Reply

Your email address will not be published. Required fields are marked *