Category menu

Raspberry Pi as an adblock server for iPad, iPhone, Android and anything else on your network

Adblocker without Jailbreak:

On my computer I find using Adblock plus a handy way to speed up surfing and hide invasive pop-up ads.

Annoyingly you can’t install Adblock on an iPad without jailbreaking it – and I’ve yet to come across a way of installing it on Android devices easily without requiring root access.

Fortunately there’s an easy way to install Privoxy on a Raspberry Pi that can block adverts (and do a few other things as well) and that works seamlessly on iOS and more or less anything you attach to your network.

You could run this software on any PC attached to your network – but with the Pi’s low power consumption  (3.5 watts) you can afford to leave it on all the time. Plus you could combine this functionality with a fileserver or an airplay speaker for a bit of extra usefulness.

Setting up your Raspberry Pi for remote control by iPad

Raspberry Pi running as an Adblock for iOS

Nice conversation piece for geeky dinner parties

First step is to prepare an SD card for your Pi – I’ve been using the default Raspbian.

Next step is to boot up the Pi with a screen and keyboard attached, and connected to your home network with an Ethernet cable. This would also work with a wireless connection, but ethernet is a bit simpler, more stable and means the Pi will run happily off a low powered USB adapter (e.g. a kindle power supply). On it’s first boot the Pi will run the config app – if you’ve already run your Pi before you can restart the config app by typing the following into the console:

sudo raspi-config

Make sure you change the default Pi password, and enable SSH in the menu. We’ll be using SSH to control the Pi remotely.

Now find your Pi’s IP address – in the terminal type:

ifconfig

This will give you some information about how the Pi is connecting to the network – make a note of the inet addr – usually 192.168.1.number (I’ll use this notation to refer to this value in the guide)

Next you can connect to your Pi using an SSH client – I’ve been using Remoter Fusion on the iPad (other SSH apps are available but I was using Remoter for something else) note that you will need to purchase SSH support in app which adds £5 to it’s price.

To connect to your Raspberry Pi with Remoter Fusion, click on discovery list -> Add Session Manually. On the Server Type choose SSH.

In the box that says SSH Hostname enter your Pi’s IP address which you found out above:  192.168.1.number then choose Manual – leave the SSH Port setting at 22 and in SSH Username enter your Pi username and SSH Password your Pi password.

Remoter Fusion iPad with Raspberry Pi

Remoter Fusion

Then connect – you might get a warning message (just accept) and then you should be seeing the Linux prompt.

Now you need to change your Pi from having a dynamic IP address (given to it by the router every time it reboots) to a static IP address which will stay the same. In the prompt type:

cd /etc/network
sudo nano interfaces

this launches nano which is a basic text editor – the following settings will depend on your Router – most routers will have a configuration page which will give you this information if you visit their configuration page – usually found on your network by typing 192.168.1.1 into a browser. The following settings worked for the BT Homehub version 3.

auto eth0
iface eth0 inet static
address 192.168.1.number
gateway 192.168.1.254
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.1.255

Press control and O and then enter to save, followed by control and X to exit.

You might want to test your settings – either by using the Ping command, or by attaching a monitor / keyboard / mouse directly to the Pi and firing up the web-browser – the Pi should be able to connect to the internet.

Installing Privoxy on your Raspberry Pi

Finally we just need to install Privoxy – with the nice simple:

sudo apt-get install privoxy

then start Privoxy

sudo /etc/init.d/privoxy start

Then you’ll need to setup Privoxy by editing the configuration file –

sudo nano /etc/privoxy/config

This is a long file with lots of options – scroll or do a search with control W and find the listen-address line. Change it to 192.168.1.number:8118

Control O to save in nano then control X to exit.

Restart Privoxy with:

sudo /etc/init.d/privoxy restart

Now on your iPad go to settings -> Wi-Fi -> your network name and then scroll to the HTTP proxy options. Choose Manual and where it says Server type your Pi’s IP address: 192.168.1.number and where it says port type 8118.

Finally go to config.privoxy.org and if it’s all working correctly you should see an enabled message.

Straight out of the box Privoxy started blocking ads for me – you can edit the exact way it does this in the configuration files. So websites like this:

Lots of Adverts

Lots of Adverts

Become websites like this:

After Adblock on iOS

Less adverts. Still rubbish.

You can take this a bit further by turning your Pi into a personal VPN for secure browsing on the go with this Lifehacker tutorial.

Probably an overkill using a Pi for this, but it is handy being able to work on the Pi using an iPad and as I mentioned before there are a few other useful things your Pi could be doing at the same time.

, , , ,

13 Responses to Raspberry Pi as an adblock server for iPad, iPhone, Android and anything else on your network

  1. Ted Tofield March 19, 2013 at 11:27 pm #

    Great work – this is a great use for my 2nd RPi :)

  2. Maze W. (@wlankabel) May 8, 2013 at 7:11 pm #

    Thanks for the great tutorial! I set it up for my iPad but I have an issue: privoxy blocks Youtube and iMessage pictures. Could you tell me how to add the necessary lines to the config file? that would help me out a lot :)

  3. Ted Tofield May 8, 2013 at 8:06 pm #

    Hi Maze W, I get the same thing with the out of the box functionality of Provoxy. I’ll post back here when I work out how to configure the actions file….

  4. Maze W. (@wlankabel) May 11, 2013 at 10:11 pm #

    thx, I’ll try the bookmarklet for youtube. I’m still looking for the domains to unblock for imessage. @Pete @Ted Tofield Looking forward to whatever you find out!

  5. josh May 27, 2013 at 2:52 pm #

    That’s awesome!

    I also found another adblock solution for ios that’s worth checking out. At http://iosadblock.webs.com, there are instructions on how you can block all Advertisements everywhere, in all of your apps, and in mobile safari.

  6. ROMSY June 26, 2013 at 7:02 am #

    Thats pretty nice and EXACTLY what i am looking for (because i want to buy a pi), but one question, is there a possibility to FORCE every Computer in MY NETWORK to use this Proxy?
    Because some of my friends have an ipad too and they looking astonished when they see i have no ads in my ipad but they have, and i don’t wanna show them to always shut on / shut off the proxy.

Trackbacks/Pingbacks

  1. Raspberry Pi adblock server « 0ddn1x: tricks with *nix - February 16, 2013

    [...] http://kimondo.co.uk/raspberry-pi-as-an-adblock-server-for-ipad-iphone-android-and-anything-else-on-… [...]

  2. Digital Holga: part 2 putting it all together - August 25, 2013

    […] a useful app to test things with. If you use the instructions in the first bit of my post about using the Pi as an Adblock server you can also set the IP address to be the same each […]

  3. Trying out the Ghost blogging platform on a Raspberry Pi - September 22, 2013

    […] Pi’s ip address – you can get this from running ifconfig – ideally you need to set up your Pi to have a static ip address […]

  4. China to Cheltenham: Great Firewalls and Web Tempora - October 17, 2013

    […] to peek round the Great Firewall of China, and for the paranoid you can protect your privacy with Privoxy or using TOR with the Onion […]

  5. How to find a Raspberry Pi on your network - Kimondo - June 29, 2014

    […] by your router (the DHCP server). Although these addresses often don’t change, they can. You can assign a static IP address which is something i’ve used in the past, or install a service like no-ip that tracks your Pi’s IP address (and makes it available […]

Leave a Reply