Creating Your Own Ad Blocker in 15 Minutes

If you’ve done just about anything on the internet, you’ll have come across some ads. Whether it’s mobile games or apps, shopping websites or social media, digital ads are everywhere. They’re often annoying, usually interruptive and, what’s worse, they’re almost certainly tracking your browsing habits.

There are a few ways to get rid of those pesky ads, but some of them are complicated and most only deal with a particular type of ad or in a certain context. For example, one of the most popular ad-blockers out there (Ad-Block) is a browser extension for Chrome and Firefox – but it only works in a browser. What happens when you want to stop ads in mobile games, or on a different computer or a different browser?

In the past, you’d have to manage ads on a per-device basis – juggling multiple ad-block extensions for different browsers and using impractical, clunky tricks (like switching your phone to aeroplane mode).

But fear not, we’ve come across a handy solution that can protect your entire network and keep it ad-free in under 20 mins! Let me introduce you to Pi Hole.

man looking at busy city full of adverts

Pi Hole helps reduce ads across your entire network, right at the source!

What is Pi Hole?

Pi Hole is open source, network-wide, ad-blocking software that bills itself as ‘A black hole for Internet advertisements’. Where Pi Hole differs from solutions like browser-based ad-blockers – which only work when browsing the web – is that Pi Hole kills ads at the network level, usually where the traffic comes in, via your router.

It can be configured to act as a DHCP server too so that it can offer more control over blocking ad-traffic to anything connected to your network (think phones, tablets, even smart TVs). As a nice bonus, your network performance will be improved because ad traffic is blocked before it’s even downloaded!

How do I set up and use Pi Hole as an ad-blocker?

Now comes the fun part: setting up your very own Pi Hole ad-blocker on your very own Bytemark Cloud Server. It’s a straightforward process that takes between 15-20 minutes. The process looks like this:

  1. Create a virtual server with a Pi Hole supported operating system and specification
  2. Run the Pi Hole install scripts
  3. Use Pi Hole as your DNS or DHCP server
  4. (Optional bonus) Block ads everywhere by combining Pi Hole with a VPN

Why Bytemark?

By choosing Bytemark as your Pi Hole host, you’ll gain:

  • We offer a generous 7-day trial – try Pi Hole for free on Bytemark Cloud.
  • We offer 10TB of transfer with your server – considerably more than competitors.
  • Bytemark owns its data centre and operate an information security management system (ISMS) in accordance with, and certified to, the ISO27001:2013 standard
  • We’re passionate about open source and operating ethically. We’re proud of our manifesto https://www.bytemark.co.uk/company/manifesto/

Installing Pi Hole

Right, to business! Let’s get up and running with Pi Hole.

1. Create a virtual server

Since Pi Hole is designed to run on a Raspberry PI, you don’t need a big spec to get started. In fact, their official prerequisites documentation lists the following base level specs for a server:

  • 52MB of free space
  • 512MB RAM
  • One of these supported operating systems
    • Raspbian: Jessie / Stretch
    • Ubuntu: 16.04 / 16.10
    • Fedora: 27 / 28
    • Debian: 8 / 9
    • CentOS: 7 (not ARM)

We’re going to use Debian 9, so open Bytemark panel and deploy a new server with the standard specs, choosing Debian 9 as the operating system.

2. Run the Pi Hole install scripts

Once the server is up and running, we need to log into the console and run the Pi Hole install scripts:

  1. Click the ‘Console’ button next to the server you just created. A new window should open.
  2. In the console, type ‘root’ as the username and enter the password that you’ll have been given when the server was created.
  3. Run the single curl command from the one-step automated install docs on GitHub:
        curl -sSL https://install.pi-hole.net | bash
  4. Follow the instructions, clicking OK where needed. It’s fine to accept the defaults for now – they can be changed later.
  5. Double check the DHCP and IP settings and information.
    The IP should be the same as the one shown in the Bytemark panel – this is important as it’s how you’ll access the admin interface later and what you’ll use across your network.
  6. Click OK and accept the rest of the defaults.
  7. Important – make a note of your admin password that Pi Hole provides!
  8. Eventually, the installation will complete and you’ll be set back into the console.
  9. Close the console window.

3. Use Pi Hole as your DNS or DHCP server

Now you’ve got your shiny new Pi Hole box set up and ready to be used, the first step is to log into the admin interface and have a look around.

During the installation, you’ll have been given a specific URL to your own admin interface, but it generally looks like this:

http://[server IP address]/admin

So, in the example I tested, I was given:

http://46.48.8.132/admin

Visit your admin URL and login with the password Pi Hole gave you. Take a look around and familiarise yourself with the interface and the various settings. You probably won’t need to regularly visit the admin site beyond updating the ad lists here and there or viewing reports (if you’re mad for stats).

Once you’re happy, the next step is to configure your network, router and devices to send and receive traffic from Pi Hole, instead of their usual source. Configuring your devices, network or router is simply too big of a task for this mere blog post as there are loads of combinations out there. However, you can visit the post-install documentation provided on the Pi Hole website to follow along and update your network as you wish.

You can change things on a device by device basis (perhaps just your work laptop or kids’ tablets) to suit your needs. At home, I’ve configured our entire network by updating our router’s DNS settings and it’s been working without a single hiccough for over a year!

4. Testing the ad blocker is working

Thankfully, Pi Hole have made it easy to check whether your network is being defended from ads by providing this handy page on their website where you can check to see if ads are loading or being halted in their tracks.

Block ads everywhere by combining Pi Hole with a VPN

The fun doesn’t have to end there though, oh no! If you’ve followed our product owner, Peter’s, recent article on setting up a VPN with Outline then you can extend your VPN’s capabilities and add your instance of Pi Hole to it, combining them both into a privacy and ad-blocking super shield!

I’d encourage a look at the comprehensive documentation from Pi Hole themselves on setting up a Pi Hole instance to work with a VPN to get started.

Go forth and block those ads

Hopefully, this article will have helped you set up and configure your own Bytemark server with Pi Hole installed. If you’ve updated your network settings to use your new Pi Hole instance then you’ll be blocking and dodging ads like never before.