There are plenty of ad blocking options out there, but many of them are far from perfect. To make matters more complicated, websites have started detecting and blocking browser ad blockers. So, what options do you have for protecting yourself from unwanted ads and trackers online?
There’s actually a simple, universal, solution that collects all ad request on your network and throws them away before they even reach your browser. Plus, it handles them at a DNS level, so there’s no way for ad blocker… blockers to detect it.
Pi Hole is a script that you can install on most Linux systems, but it got its name from the Raspberry Pi. The Pi makes a perfect small device that you can install Pi Hole on, connect it to your network, and basically forget it. If you’re wondering, the “Hole” part of the name is referring to a black hole because that’s essentially what it acts like for ads.
Planning Your Configuration
Pi Hole is ridiculously versatile. You can place it a just about any place along the path from your network to the Internet. It only needs DNS input and a server to send the cleaned traffic to. The traffic can come from a single device, multiple devices, or your router itself, and it can go straight out to an external DNS server, your router, a local proxy like DNSCrypt, or just about anything that can handle DNS traffic.
Pick Your Device
Despite its name, you can install Pi Hole on most Linux systems, regardless of what kind of device they’re on. Running Pi Hole on a regular Linux PC, a custom router, or even a virtual machine isn’t out of the question. The choice is entirely yours.
Pick a device that fits best into the flow of traffic that you’re looking to design. Remember that you can run a Raspberry Pi with multiple services on it. If you want, you can configure a Pi as a router itself with Pi Hole to handle DNS and an OpenVPN client to handle traffic from multiple devices.
There are loads of ways that you can configure your network. Unless you want to do something really creative, there are a couple of fairly common ones.
Simple Router DNS
This is easily the most simple configuration that you can use. All you need to do is install Pi Hole on a device on your network. Then, configure your router to use that device’s IP address for DNS. Everything else on your network will flow as usual. The only downside here is that you can’t use a VPN, unless the VPN doesn’t use Pi Hole or you use the router to connect to the VPN.
Second Caching DNS
If you already have a DNS caching server, like one integrated in your router through pfSense or another more advanced router OS, you can still take advantage of that DNS functionality with Pi Hole. The easiest way to do so is by configuring the devices on your network to use Pi Hole for DNS directly. Then, set Pi Hole to export its DNS requests upstream to your router. The router can continue functioning normally and using the same external DNS as before. Once again, if you have individual devices using VPN connections, you’re going to need to either use your router to connect or forego the Pi Hole on those devices.
Pi OpenVPN Client
Finally, this is the solution for VPN users. If you have a mixed network with some devices using a VPN and others not, your best bet is to use your Pi as both a router with a VPN client and the Pi Hole. Actually, you’d need two Pi Holes, one for the VPN and one for normal traffic. It’s not ideal, but it will work.
The non-VPN network will look almost identical to the first simple configuration. For the VPN one, you need to set up a Pi as router. That router will also run an OpenVPN client and Pi Hole. Configure the computers that you want on the VPN to connect to the router. Configure the Pi to route all traffic through OpenVPN to your VPN provider. Then, configure the Pi to use Pi Hole as its DNS and Pi Hole’s upstream DNS to be your VPN provider’s server.
Install Pi Hole
Okay, now that the theory and planning is out of the way, it’s time to actually install Pi Hole. It’s actually very simple. First, make sure that you have curl installed on the Raspberry Pi or wherever you plan on installing Pi Hole. It also helps to have sudo. Since you’re probably going to be using Debian or Ubuntu(it’s a good idea), just make sure to install curl.
$ sudo apt install curl
Next, paste the following line into the terminal and run it. It will download and begin the Pi Hole installer script.
$ curl -sSL https://install.pi-hole.net | bash
To start off, the Pi Hole install script will start off by making sure you have root access, either through sudo or that you’re running the script as root. Either way works.
The Pi Hole install script will start up and prompt you to begin the install.
Next, it’ll ask you which DNS server you want to export to. Choose any one that you like.
Then, it will ask you if you want to use the current IP to set a static IP address. Unless you have a very good reason not to, leave it exactly as it it.
Set up the Pi Hole web interface for monitoring. It’s very good, so definitely use it.
Finally, the script will tell you that the installation is complete and give you and admin password. Take note of it. You can’t change it, and you’ll need it to access the full admin web interface.
The Web Interface
The web interface that comes with Pi Hole is actually very nice. The layout is simple, and it’s a great way to see exactly what the Pi Hole is blocking. You will be surprised with the amount of garbage traffic clogging up your network. Use the “Login” tab on the side to sign in with your password.
Take a look around. The main “Dashboard” tab shows you how many requests total have come through the Pi Hole as well as how many of those were blocked. It also includes nice graphs of your request and a listing of the domains that are being contacted. As you let it run, Pi Hole will populate the graphs and give you visualized data on what’s happening with your network.
Pi Hole Upstream Servers
Under the “Settings” tab, you’ll find a set of other tabs across the top. Click on the “DNS” one. Under that tab, you’ll find the list of DNS servers from the install script. There are also a couple of options there for adding in custom DNS servers. Configure it the way you want. In the future, that’s the place you’d go to change things.
Configure Your Client DNS
Now that your Pi Hole is running, you need to configure the devices on your network to connect through it. The exact circumstances are going to be unique to your network, but some things are universal.
All routers are different. Find the DHCP options for your router and locate the “Static DNS” fields. Set the IP address of your Pi Hole as the first entry and apply the change. Your router will begin diverting all DNS requests through the Pi Hole.
If you opted to connect via individual computers, you’ll need to configure each one to use Pi Hole instead of your router for DNS.
Changing your DNS server in Windows 10 is unnecessarily complicated, but it’s still totally doable. Click on your “Settings” or “Control Panel” option under the main menu. Click on “Network and Internet” and move on to the “Network and Sharing Center.”
Click on “Change adapter settings.” Then right click your adapter and select “Properties.” On the “Properties” window, select “Internet Protocol 4,” tap the “Properties” button below. In the next window, select the radio button to use specific servers. Type in the IP address of your Pi Hole and save.
Linux distributions have different ways of handling Network configuration, but most use NetworkManager in some form to provide you with a graphical interface to manage networking with.
Open your desktop environment’s Settings app. Look for the networking settings. On GNOME, it’s called “Network.” Select the network interface that you’re using to connect and open its settings. On GNOME, it’s the gear icon in the lower right corner. Select IPv4. In any case, the DNS server settings will be located under the IPv4 heading. Enter in the IP of your Pi Hole. Save and apply.
Pi Hole is awesome. It will probably block thousands(literally thousands) of requests on your network within a few hours on your network. This is oddly especially true when you’re using streaming services and streaming devices. While it was hard to cover the whole process from start to finish here, you should have a general idea of how to set up the Pi Hole, what it can do, and how you can integrate it into your network.
Because Pi Hole is so super light and flexible, you can install it just about anywhere on your network and even run multiple instances in different places. The choice is entirely yours. Any way you do it, though, you will notice some pretty surprising results, and your network is probably going to be faster for it.