How to Set up Pi-hole on Raspberry Pi 4?
As much as we all hate ads, those ads are a major source of revenue for most of the websites. I personally don’t have a problem with ads as long as they are not intrusive. That’s why products likeAdblock Plus and Ublock Originexist, but what about other devices? EnterPi-hole, a network-wideadblockerwhich allows you to filter out ads from your entire network with a click of a button. Let’s set it up on new Raspberry Pi 4.
Pi-holeis 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 includingRaspbian, Fedora, Debian, Ubuntu, and CentOS. you may also put it in aDockerand run it onWindowsandMacas well. I’ll focus on installing this onRaspberry Piin 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 withRaspbian OS. Even if you don’t, installing Raspbian on Raspberry Pi is easy, flash theRaspbian imageon an SD card usingEtcher, plug it in the Pi, and you have a working Raspberry Pi. You canread more about it here.

To get started,open the TerminalWindow 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 settingsand wait for the setup to finish. Justnote down the IP address and the passwordthat 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 canfollow the guide hereor 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 consolewith 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 generally192.168.1.1but check the back of your router to be sure.Navigate to the DHCP server settings, findDNS server sectionandreplace the DNS entrywith the IP address of your Raspberry Pi. You would have toremove all the other DNS serversfrom the list otherwise Pi-hole won’t work.Save the changes and restart. To make things easier, you may take help of thisin-depth guide to change DNSon 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. PressCMD + SPACEkey to bring up spotlight search and type ‘System Preferences‘ and hit enter on the result. FindNetworkfrom the options and double click toopen the Network Settings.
You’ll see the DNS Server, to edit the entry.Click the lock buttonon the bottom left of the window. It would ask your login credentials, enter the correct details and thenclick Advanced.
Click DNS andclick the + buttonto add a DNS entry.Enter the Pihole IPand 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’re able to always manually block or enable those. Try it and let me know if you face any problem in the comments below.
Works as an in-house Writer at TechWiser and focuses on the latest smart consumer electronics. Closely follows the latest trends in consumer IoT and how it affects our daily lives. You can follow him on Twitter. Yes, he sometimes speaks in Third Person.