Page 1 of 1

RasPi Ad-Blocker

Posted: Thu Dec 12, 2013 8:43 pm
by codac
Hi guys,

I'm trying to set up my RasPi as an Ad-Blocker, following this tutorial:
http://learn.adafruit.com/raspberry-pi- ... l-software

Unfortunately at this point...
Congratulations, you should now be blocking ads with your Raspberry Pi. You can test that it's working by executing the following:
dig doubleclick.com
And you should see that it gets routed to the 192.168.42.49 IP address:
...I wont see the routed IP address (in my case 192.168.1.1) but the proper IP address of this website.

I have no idea what the issue might be.
Herre are my settings:
/etc/dnsmasq.d/dnsmasq.custom.conf

Code: Select all

interface=wlan1
dhcp-range=wlan1,192.168.1.100,192.168.1.140,2h
# Gateway
dhcp-option=3,192.168.1.1
# DNS
dhcp-option=6,192.168.1.1

dhcp-authoritative
/etc/resolv.conf

Code: Select all

nameserver 192.168.2.1
sameserver 8.8.8.8
nameserver 8.8.4.4
/usr/local/bin/dnsmasq_ad_list.sh

Code: Select all

#!/bin/bash
ad_list_url="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&sh$
pixelserv_ip="192.168.1.1"
ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf"
temp_ad_file="/etc/dnsmasq.d/dnsmasq.adlist.conf.tmp"

curl $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

service dnsmasq restart
Has anyone an idea?

Thank you for your help!

Re: RasPi Ad-Blocker

Posted: Fri Dec 13, 2013 8:20 am
by DougieLawson
Can you post the output from

ifconfig -a
route -n

Re: RasPi Ad-Blocker

Posted: Fri Mar 21, 2014 10:27 am
by wimble
I've just set this up on my configuration (where, actually, I'm not doing this on a Raspberry Pi, but on a QNAP NAS server. But the principles the same. File names are different though.)

The problem is that the tutorial doesn't change the dnsmasq configuration to read the shiny new list of redirects.

Edit your dnsmasq.conf file, and add the line:

Code: Select all

conf-file=/opt/etc/dnsmasq/dnsmasq.adlist.conf
and then restart the service.

Re: RasPi Ad-Blocker

Posted: Fri Mar 21, 2014 10:42 am
by mikerr
I posted a somewhat simpler version a while back:

http://www.raspberrypi.org/phpBB3/viewt ... 1&p=383760

hosts file based, so no messing with DHCP and dnsmasq etc

Re: RasPi Ad-Blocker

Posted: Fri Mar 21, 2014 5:54 pm
by wimble
The advantage with the dnsmasq solution is that it works for your entire network in one go. No faffing about with individual host files on each machine. And in the case of iPhones and unrooted Android devices, you can't edit the hosts file on the specific devices. So patching it through the DNS server is the easiest solution (either that or proxying all of your http traffic...)