Skip to content

Instantly share code, notes, and snippets.

@0x-2a
Forked from martinsohn/edgemax-ad-blocker-dnsmasq.md
Last active November 3, 2020 22:38
Show Gist options
  • Save 0x-2a/805e1da3cf599c5f73d15b95c561b0cc to your computer and use it in GitHub Desktop.
Save 0x-2a/805e1da3cf599c5f73d15b95c561b0cc to your computer and use it in GitHub Desktop.
HOWTO Ubiquity EdgeMAX Ad & Malware Blocking Content Filtering using EdgeRouter as dnsmasq server

Ubiquity EdgeMAX Ad Blocking Content Filtering using EdgeRouter

This is based on sudo -i && vi /config/user-data/update-adblock-dnsmasq.sh

#!/bin/bash

ad_list_url="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext"
#The IP address below should point to the IP of your router or to 0.0.0.0
pixelserv_ip="0.0.0.0"
ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf"
temp_ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf.tmp"

curl -s $ad_list_url | sed "s/127\.0\.0\.1/$pixelserv_ip/" > $temp_ad_file

if [ -f "$temp_ad_file" ]
then
        #sed -i -e '/www\.favoritesite\.com/d' $temp_ad_file
        mv $temp_ad_file $ad_file
else
        echo "Error building the ad list, please try again."
        exit
fi

/etc/init.d/dnsmasq force-reload
sudo -i
chmod a+x /config/user-data/update-adblock-dnsmasq.sh
sh /config/user-data/update-adblock-dnsmasq.sh
(crontab -l ; echo "56 4 * * 6  /config/user-data/update-adblock-dnsmasq.sh") | crontab -

Visit the following sites to confirm the ad-blocker is working:

References

This is based on a YouTube video by Willie Howe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment