codac
Posts: 33
Joined: Sun Aug 18, 2013 9:40 am

RasPi Ad-Blocker

Thu Dec 12, 2013 8:43 pm

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!

User avatar
DougieLawson
Posts: 35836
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RasPi Ad-Blocker

Fri Dec 13, 2013 8:20 am

Can you post the output from

ifconfig -a
route -n
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

wimble
Posts: 34
Joined: Tue Feb 05, 2013 9:52 am

Re: RasPi Ad-Blocker

Fri Mar 21, 2014 10:27 am

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.

mikerr
Posts: 2774
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: RasPi Ad-Blocker

Fri Mar 21, 2014 10:42 am

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
Android app - Raspi Card Imager - download and image SD cards - No PC required !

wimble
Posts: 34
Joined: Tue Feb 05, 2013 9:52 am

Re: RasPi Ad-Blocker

Fri Mar 21, 2014 5:54 pm

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...)

Return to “Networking and servers”