How to block ads on your network with the Raspberry Pi

Share on Facebook38Share on Google+0Tweet about this on TwitterShare on Reddit2.1kShare on StumbleUpon0Pin on Pinterest9

About: You can use your Raspberry Pi as a DNS server which blocks ads on all your devices connected to your network. This means your Iphone, Android phones and Ipads can now block ads without needing to root them or do any changes to them. We’ll be using Pi-hole to put on our Raspberry Pi and the install is very simple. I will be using a dedicated Raspberry Pi with a clean install of Raspbian on it. If you are using your Pi for anything else like a web server or have edited the DNS settings then the install may break your setup. I would recommend setting up your Pi-hole on a clean install to prevent anything like this from happening or backup your Pi before running the install.

Objective: To demonstrate how to set up our Raspberry Pi as a DNS server that blocks ads on all devices network wide.

Material: You will need the following:

Instructions: Installation of Pi-hole is very simple. Start off by simply typing the following command in the terminal

This will begin the download and installation. After a while you should get a few prompts about whether you want to set your Raspberry Pi to use a static IP. Make sure you select Yes. A static IP will keep the same IP address on the Raspberry Pi after you restart it. This will be important when we set up the router in a few steps. We’ll be setting the router to point it’s DNS to our Raspberry Pi, and if the IP would change then our DNS would not work.

pi-hole2

Keep clicking Next until you get a prompt about which protocols to use for blocking ads. Make sure you select IPv4 and IPv6. Use the space bar to select both options. Many ads are now using IPv6 and we need to make sure to block them for maximum efficiency.

pi-hole1

 

That’s pretty much it. You’ll get the following screen when you’re done.

pi-hole4

Make sure you copy down the IP address. We will be using this in the next step to set up the router. Now everyone has a different router. I will show you how to set the DNS on my Netgear router, but it should all be similar for each router. Go ahead and login to your router. The IP address is usually 192.168.1.1 After logging in find your Internet Setup. You should see something about DNS settings. Make sure to select “Use these DNS servers” or something similar and setup the first IP address to the IP that you wrote down from before for your Raspberry Pi. The second DNS IP address set it as ‘8.8.8.8’. These are Google’s DNS servers and in case our Pi is not working or turned off everything will route through Google’s DNS servers, so we shouldn’t see any hiccups when using the internet, like seeing ads again.

pi-hole3

That’s it. You should now be able to surf the web and see if your ads are blocked. If it’s not verifying your DNS settings on the router may not be set to the Raspberry Pi’s IP address. You can also view your Pi-Hole statistics by going to your Pi’s IP address/admin. For my example I would go to http://192.168.1.18/admin and I would see the following screen.

pi-hole5

If you have any questions or concerns then just comment below. Also please donate to the Pi-Hole project here: http://pi-hole.net/donate/

Share on Facebook38Share on Google+0Tweet about this on TwitterShare on Reddit2.1kShare on StumbleUpon0Pin on Pinterest9

13 Comments

  • Mark

    January 10, 2016

    Great write up – how could I use a service like adfreetime or unblock us with this? Do I set the pihole to use the adfreetime dns or something else?

    Reply
  • Adam

    January 10, 2016

    Sometimes it’s hard to distinguish between an advertisement and a pop up menu for a website you use. For traditional ad blockers, you can temporarily disable blocking to resolve this issue. Is there a quick solution like this for Pi-Hole?

    Reply
    • Tyler

      January 10, 2016

      It is DNS-based. It appears they are just blocking ad networks. This approach shouldn’t affect menus, but may display empty pop-ups on some sites.

      Reply
  • Daniel

    January 10, 2016

    Really noobish question… Never done something like this, so It looks super easy to install, but the only thing thats may be obvious but is not stated in the post is, you connect your raspberry pi to your modem, right? as in Ethernet connection, right? another question I have, since I use an adblocker, like uBlock, which sometimes blocks sourceforge which sometime has good software, (sometimes), does Pi-Hole block it? if so, does can you willingly view the content thats blocked? thanks in advanced, and sorry if these questions are obvious.

    Reply
  • Cody

    January 10, 2016

    “…weather you want to set your Raspberry Pi to use a static IP. Make sure you select Yes.”

    My router has a reserved address for the Raspberry Pi. Can no be selected in this case?

    Reply
    • dayz

      January 10, 2016

      Yes as long as you make sure the Raspberry Pis IP address is always the same. Weather setting it on your router or on the Pi.

      Reply
  • Sam

    May 16, 2016

    Thanks got this to work based off of you tutorial.

    Reply
  • Wade

    June 13, 2016

    I’m using a Lynksys WRT1900AC router and I cannot for the life of me find the DNS settings. Any advice? I’m fairly new to this stuff.

    Reply
    • dayz

      June 14, 2016

      It is usually on the first setup page. If you can’t find it you can set all your devices DNS to point to the Router instead as a work around. Thats how I have it set up for my Xbox and Iphone since my router doesn’t always use the DNS for my Pi.

      Reply
  • Pingback: Fix Xbox Live Achievements not popping up when using Pi-Hole – Kamil's Lab

  • Pingback: How to turn your Raspberry Pi into a Home VPN Server using PiVPN – Kamil's Lab

  • Pingback: How to Build a Raspberry Pi TorrentBox – Kamil's Lab

Leave a Reply