Block all Ads with a Pi-Hole
Tags: adblock, pihole, dns, raspberrypi
Published: 2020-09-29 10:44:19

---
title: Block all Ads with a Pi-Hole
published: true
date: 2020-08-14 12:06:07 UTC
tags: adblock,pihole,dns,raspberrypi
canonical_url: https://medium.com/innovation-incubator/block-all-ads-with-a-pi-hole-7508313ed235
---

![](https://cdn-images-1.medium.com/max/1024/0*sgbDbV3c4NWEnRBC.png)

Seeing ads on every site you visit and between the movies you see are being nightmarish in times where you relay on online websites for work as well as leisure.

There are a number of ways to avoid this including browser-based plugins such as Adblock that Blockout ads that appear on your viewport. But these are limited to a particular browser or at instances the specific computer. There are devices like a mobile where even games show up ads that cannot be blocked by this method, which is where a network-wide ad-block comes into the picture.

**Pi-Hole is a DNS Sinkhole on a 5$ Pi zero on a network**

### **What is a DNS Sink Hole?**

DNS Sinkholes are black holes in the Network that feeds on requests from preidentified blacklisted domains and returns a null address while forwarding the non-blacklisted domain requests.

### **Setting up a Pi-Hole**

1. **Setup a Raspberry Pi**

i)Use any Raspberry Pi,

ii)Connect it to power

iii)flash an os to the sd card(such as raspian: [https://www.raspberrypi.org/downloads/raspbian/](https://www.raspberrypi.org/downloads/raspbian/)) to it.

This can be done by tools like balena etcher.

iv)Insert the sd card to the pi and power it on

**2. If you’re doing a headless install like us (no monitor/keyboard required), you’ll need to enable SSH before booting up the Raspberry Pi**

i)Replug your SD card to allow Windows to recognize the new Raspbian partition layout

ii)You should see a partition named boot

![](https://cdn-images-1.medium.com/max/366/0*ebgIGhsn-XjdpSuZ.png)

iii)Create a file inside the drive “ **_boot_** ” folder called “ssh” with no extension

![](https://cdn-images-1.medium.com/max/1024/0*8OasgV1e-8q1_72i.png)

**3)Plug your SD card into the Raspberry Pi followed by networking, and then power.**

**4)Since we did a headless install, we’ll need to search for our raspberry pi's IP address so we can access it over SSH.**

This can either be done through the Routers ip listing or by tools like angry ip scanner. Look for the hostname “raspberrypi”.

**5)Now that we’ve found our Raspberry Pi’s IP address + MAC Address, we need to assign it an INTERNAL/LOCAL static IP address.**

i)This process is going to vary wildly based on which router/DHCP server you use, so we’d recommend Googling your router’s model name/number (can be found on the back) + “how to set static IP” (ex: “Netgear R5000 how to set static ip”).

ii)Log in to the admin page either with the Iogin credentials listed on the back of the router, or by googling the model number of the router along with “default password”. Some routers use a randomly generated default password, so googling will not work for those.

iii)Once logged in, look for a tab labeled “_DHCP Reservation_”, “_Static IP Assignment_”, or something along those lines.

![](https://cdn-images-1.medium.com/max/189/0*HtBKAewqzc8wOgdF.png)

iv)either choose the mac address with hostname pi or enter the mac id you gathered with angry IP scanner and assign an IP not used by any other device in ur network.

v)Hit Apply to restart your router.

**6)Restart your Raspberry pi to ensure it boots to the new config**

**7)Access the Raspberry Pi over SSH With any SSH Client tool such as Putty.**

```
Username:pi

Password:raspberry

\*these are the default username and password
```

**8)Now that we’re logged in over SSH, start by changing the default password, and updating the Raspberry Pi.**

To change the user password enter the command “passwd” and press enter.

1. You’ll then be prompted to enter the current password (this is “raspberry” so enter that)
2. Then enter your desired new password

Once that is done type in

```
sudo apt update
sudo apt upgrade -y
```

### **Our Raspberry Pi is now updated, set to a secure password and ready to install Pi-Hole onto!**

**9)Copy the Pi-Hole install command from their website, paste it into the SSH client,**

```
wget -O basic-install.sh https://install.pi-hole.net
sudo bash basic-install.sh
```

**10)Press Enter until you get to the “Choose An Interface” page. The default “eth0” interface for Ethernet users should be selected by default. Press Enter to continue.**

“wlan0” should be selected if you’re using WiFI

“en0” if your using lan

**11) On the next screen, select your upstream DNS provider. This is where requests will be forwarded if they’re not blocked by Pi-Hole (ie. if they’re not found in it’s block/black lists). We will be using Google DNS, and if you don’t know what this means, stick with that.**

**12) The following screen allows you to select which of the default block list’s you’d like to use. We will leave these all on, but you can use your arrow keys and space bar to (de)select any of them as you wish. Press Enter to continue**

**13)Next up, it will ask you if which IP protocols you want to block ads over, leave this at the default unless you know what you’re doing. Press Enter to continue.**

**14)The next screen will list the IP address of the Raspberry Pi and the IP of your router, assuming you’ve set a static IP, just click Enter to continue.**

1. If you get a screen about an IP conflict, just ignore it and click Enter to continue

**15)You’ll then be asked about the web interface, web server, and logging modes. Leave these all at default by clicking Enter.**

**16)After all that, Pi-Hole is going to do a bunch of stuff, and it might take a couple minutes so sit back until you’re greeted with an “Installation Complete!” page. This will list the IP and password for the Pi-Hole web interface.**

17) **Copy the IP into your browser, and log with the listed password. Huzzah! You now have a functioning Pi-Hole installation**

![](https://cdn-images-1.medium.com/max/1/0*YWjELuDhFMDz1ZXU.png)

**18)Setting Up Pi-Hole to Run on Your Devices / Whole Network**

To enable Pi-Hole on a device-by-device basis, you’ll need to manually set the DNS IP address in your device settings.

1. For each of these, substitute the IP in the tutorial for the IP of your Raspberry Pi

iPhone refer to [**Link**](https://appleinsider.com/articles/18/04/22/how-to-change-the-dns-server-used-by-your-iphone-and-ipad)

Android Refer to [**Link**](https://support.opendns.com/hc/en-us/articles/228009007-Android-Configuration-instructions-for-OpenDNS)

**To enable Pi-Hole on a Router level, meaning it will work on all your devices automatically, you’ll need to configure your router’s DHCP server’s default DNS settings.**

This process is going to vary wildly based on which router/DHCP server you use, so we’d recommend Googling your router’s model name/number (can be found on the back) + “how to set DNS servers” (ex: “Netgear R7000 how to set DNS servers”).

**19) Improving the performance**

1. **To enable some common whitelisted false-positives run the command listed here:** [**https://github.com/anudeepND/whitelist**](https://github.com/anudeepND/whitelist)
2. **For some great info on the Pi-Hole web interface read the lower portion of this tutorial:** [**https://www.smarthomebeginner.com/pi-hole-tutorial-whole-home-ad-blocking/#Configuring\_Your\_Router\_8211\_Whole\_Home\_Ad\_Blocking**](https://www.smarthomebeginner.com/pi-hole-tutorial-whole-home-ad-blocking/#Configuring_Your_Router_8211_Whole_Home_Ad_Blocking)

* * *