Pi-hole is a simple server that sits between your router and connected devices and filters out ads. It works like this, the router receives all the queries from the devices and instead of routing those to the Internet, the requests are sent to the raspberry pi and the Pihole then cherry-picks the ads and blocks them right there. All the other requests are then forwarded to the internet. Not only you can block ads on every device on the network, but it can also let you restrict access to specific websites on your network and make the network faster. Simple enough?
1. Installing Pi-hole
Pi-hole works on a variety of devices and a number of different operating systems including Raspbian, Fedora, Debian, Ubuntu, and CentOS. You can also put it in a Docker and run it on Windows and Mac as well. I’ll focus on installing this on Raspberry Pi in this article because it is relatively cheaper than dedicating an entire machine for just one program and fun to work with. I’ll assume you have a brief idea of what Raspberry Pi is and have one up and running with Raspbian OS. Even if you don’t, installing Raspbian on Raspberry Pi is easy, flash the Raspbian image on an SD card using Etcher, plug it in the Pi, and you have a working Raspberry Pi. You can read more about it here. To get started, open the Terminal Window on the Raspberry Pi and enter the following command.
It would begin the installation process which may take a few minutes so grab a seat. It would start by updating the Raspberry Pi itself and then proceed to install Pi-hole.
You just have to follow the on-screen commands to install Pi-hole on your computer. Select the default settings and wait for the setup to finish. Just note down the IP address and the password that you set for the Pi-hole, we’ll need it later.
We’ll assign a Static IP to the Raspberry Pi to ensure the pi-hole works even if the router restarts. The setup would do that automatically, however, it would be advisable if you manually set it on your router. You can follow the guide here or search the Internet on how to assign static IP address on Rpi. Now, the Pi-hole server is up and running on the raspberry pi, we can log in to the dashboard to make the final changes. Open the web browser, type “https://pi.hole/admin/” in the URL bar, and hit enter. Log in to the console with the password you set during the setup process. If you don’t remember the password, you can easily change it in the terminal window with the following code.
Setup Other Devices Do note that Pi-hole is not actually blocking any traffic, it simply assigns invalid DNS to ads, so the queries never reach the destination. For the setup to work smoothly, we’ll have to change the DNS on all the devices including the router. I’ll list the steps for Android, iOS, Mac, Windows, and your router.
2. Change DNS on Router
Open the router settings by entering the IP address in the URL bar of a web browser. It is generally 192.168.1.1 but check the back of your router to be sure. Navigate to the DHCP server settings, find DNS server section and replace the DNS entry with the IP address of your Raspberry Pi. You would have to remove all the other DNS servers from the list otherwise Pi-hole won’t work. Save the changes and restart. To make things easier, you can take help of this in-depth guide to change DNS on every device.
3. Change DNS on Windows
Open Network Settings on your Windows PC and make sure it is connected to the router. Navigate using the following steps to change the DNS server on the Computer. Start > Control Panel > Network and Internet > Network and Sharing Center > Under Active Networks > Select your Wifi Connection > Properties > IPv4 Properties > Replace DNS entry with Pi-hole IP.
4. Change DNS on Android
Make sure your Android smartphone is connected to the wifi router access point. Follow the steps below to change the DNS on your Android smartphone. Settings > Networdk & Internet > WiFi > Tap Settings button next to Wifi Name > Tap Edit button on top > Tap IP Settings > Select Static > Enter IP Address for the device, Router Gateway > and DNS Servers. Also, make sure you don’t leave any DNS entry empty, otherwise your smartphone would automatically route requests to Google DNS.
5. Change DNS on iOS
Just like Android smartphone, changing DNS servers on iOS is easy and similar in terms of steps. You don’t even have to assign a static IP to the iPhone. Follow the commands below to set DNS. Settings> WiF i> Tap Wifi Name > Tap Configure DNS > Select Manual > Enter Pihole DNS > Save.
6. Change DNS on Mac
To change the DNS on Mac, open the System Preferences. Press CMD + SPACE key to bring up spotlight search and type ‘System Preferences‘ and hit enter on the result. Find Network from the options and double click to open the Network Settings.
You’ll see the DNS Server, to edit the entry. Click the lock button on the bottom left of the window. It would ask your login credentials, enter the correct details and then click Advanced.
Click DNS and click the + button to add a DNS entry. Enter the Pihole IP and click OK. Your Pihole DNS is now configured on the Mac computer.
7. Change Upstream DNS in Pihole Console
This is the last step. We need to change the Upstream DNS server entry in the Pihole console so that it correctly redirects the requests to the router. Open the Pihole Admin console by typing the following address in the URL bar “https://pi.hole/admin/“. Login, click Settings and navigate to DNS tab.
In this tab, uncheck any DNS server that may be enabled on the left. Check “Custom 1( IPv4)” box and enter your Wifi Router’s gateway address. Click save and you’re Pihole is active.
8. Use Pihole
You can keep track of all the ads you’ve blocked, queries which are allowed on a clean dashboard. It also allows you to manually block websites so it can be more than just a website blocker. Website blocking would only work as long as DNS is configured on the client device and it can be awesome if you have kids in your home. You can manage all the devices, enable and disable adblocking for each device, and make your entire network faster.
Closing Words This was an in-depth guide on installing the Pihole on a raspberry pi. It works really well and blocks ads instantly across the network. It does miss a few ads here and there but you can always manually block or enable those. Try it and let me know if you face any problem in the comments below.