Pi-hole is free and open source software for setting up a DNS (Domain Name Service) and DHCP (Dynamic Host Configuration Protocol) server with built-in functionality to be able to block ads, trackers, and other websites. As a DNS server, it is setup to block unwanted / undesired traffic on your entire network without needing to install anything on your smartphone, laptop, or other devices. You simply setup the Pi-hole, configure your network, and everything just works for all devices connected to the network.
Most often Pi-hole is talked about as being used for blocking website advertisements on a home network. This is just one very specific use case. Pi-hole can be used on any network, so long as the hardware it’s installed on has the resources to handle all the DNS queries of that network. As such, you can also install Pi-hole on a small business network to block undesired websites, and this is a really great cheap option for businesses.
Pi-hole works on the DNS (Domain Name Service) level. DNS is what your compute uses to turn a domain name (such as build5nines.com
) that is typed into a web browser, into the IP Address (such as 8.8.8.8) that the computer connects to in order to download and display the requested web page. This DNS Lookup is performed not just within the web browser, but by any software that is requesting to communicate with a server on the Internet; such as any apps on your smartphone, computer, tablet, or other devices. By setting up Pi-hole as the DNS server on your network, it intercepts all DNS name resolution requests, and enables you to block those that you don’t want; such as ads, trackers, or even any NSFW websites.
Now, let’s dig into setting up Pi-hole on a Raspberry Pi!
Prerequisites
Pi-hole is server software that runs on LInux. You will need a computer that runs linux to install it, and that can be a Raspberry Pi (as this article discusses) or Pi-hole can even be run in a Container to integrate it within any network.
Since we are looking at setting up a Raspberry Pi to run Pi-hole, you will need the following items:
- 1x Raspberry Pi – A Raspberry PI 2, 3, or 4 will work, as will a Raspberry Pi Zero*
- 1x microSD Card (4 GB or larger) – This provides the storage to install the Raspbian Linux operating system on the Raspberry Pi.
- 1x Micro-USB Power Cable or Supply – This will be used to power the Raspberry Pi.
- 1x Ethernet cable – This is used to connect the Raspberry Pi to your network router.
- 1x Raspberry Pi case (Recommended) – There are a number of cases for the Raspberry Pi; while not required it is recommended.
*If you choose a Raspberry Pi Zero, then you will need an adapter for connecting an Ethernet cable, as this version does not have an integrated Ethernet port. The Raspberry Pi 2, 3, and 4 all have integrated Ethernet ports onboard.
Here are some links where you can buy the items needed to setup your own Raspberry Pi Pi-hole:
- CanaKit Raspberry Pi 4 Starter Kit
- CanaKit Raspberry Pi 3 Kit with Premium Clear Case and Power Supply
- SanDisk 16GB Ultra MicroSDHC UHS-I Memory Card
- Raspberry Pi 4 Model B
Before Pi-hole can be installed on a Raspberry Pi, you will need to install Raspbian Linux on the microSD card. When installing Raspbian on the Raspberry Pi, I personally recommend using the Raspbian Buster Lite image and configure the Raspberry Pi to be headless (aka not need any display or keyboard). You can create a file named
ssh
on the SD card after flashing the image, then when the Raspberry Pi is plugged into Ethernet and powered on, you can use SSH to connect to it over your network. Just look up the IP address it’s assigned from your router and use the username / password ofpi / raspberry
to login to it.
Install Pi-hole
Once the Raspberry Pi is powered on you will need to install Pi-hole. This can be done by connecting it to a display & keyboard, or doing it headless by connecting to it over SSH. I recommend the headless setup (as mentioned above) as that will enable you to easily manage the Raspberry Pi device later on from anywhere on your network as needed.
To install Pi-hole on the Raspberry Pi, once booted up into Raspbian Linux, run the following command to perform the automated install:
curl -sSL https://install.pi-hole.net | bash
Once the script is downloaded and begins executing, follow the guides steps to setup the Pi-hole configuration. If you are unfamiliar with the settings to choose, then just go with the default values to get up and running. Everything can be changed later anyway if necessary.
Setup Pi-hole as your DNS Server
Once Pi-hole is installed on the Raspberry Pi, you will want to go into your router configuration and perform the following 2 actions:
- Set the Pi-hole Raspberry Pi device to be assigned a Static IP Address. This will ensure the Raspberry Pi is assigned the exact same IP Address on your network every time it boots up.
- Configure the Custom DNS Settings in your router configurations to use the Pi-hole’s IP Address. This will enable your network to use the Pi-hole DNS server instead of your ISPs.

After Pi-hole has been installed, a static IP Address is assigned, and the Custom DNS Server settings are configured on your router, the Pi-hole will begin to block ads, trackers, and other unwanted traffic it’s configured to with the blocklist and whitelist features set.
Remotely Accessing and Managing Pi-hole
Once the Pi-hole is setup on your network, you can easily use a web interface to manage the Pi-hole configurations, as well as view the status of the DNS queries it’s been allowing and those it’s blocked. This is provided for you with a nice web based dashboard that can be accessed at the IP Address of the Pi-hole like this: http://<ip-address>/admin
When you first configured the Pi-hole it will have given you a password that you can use to login to the Pi-hole Dashboard web app.

Setup Whitelist and Blocklist of Sites / DNS Names
When the Pi-hole is setup, it will be pre-configured with some Blocklists that block certain websites. This will be setup for you if you choose the default values during the installation. If you find any sites are being blocked that you don’t want to be, then you can use the whitelist feature to explicitly allow those particular domains. Also, if you specifically know certain sites you want blocked, you can use the blocklist to do that as well.
The default blocklists setup include a few that will generally block DNS requests for domains that host Ad platforms and online Trackers. Blocking ads is the most noted use of Pi-hole. However, you can use this to import any Blocklist you want, including one you create yourself, or even those created by the community.
For example, one that I found useful from the community is a blocklist hosted on GitHub and managed by Chad Mayfield that contains a massive list of adult or pornographic website domains. Using the Pi-hole and Chad’s blocklist, I am able to block MANY of the pornographic websites on the Internet that I especially do not want my young kids to be accessing by clicking some random link or advertisement on the web. Also, if you set this up for a small business you can help ensure you get the same protections there too!
To add Chad Mayfields porn blocklist to your Pi-hole, go into the Settings -> Blocklists interface within the Pi-hole dashboard, and add the following URL:
https://raw.githubusercontent.com/chadmayfield/my-pihole-blocklists/master/lists/pi_blocklist_porn_all.list

Block Social Media and Messaging Services
You can use the blocklists feature of Pi Hole to create lists of all kinds of different sites and services you wish to block. You can even pull in blocklists that others have created to enhance your network protection and site / service blocking capabilities. Included in this mix, is the ability easily block certain social media services; like blocking TikTok.
I have put together a few blocklists that can be used to block social media and messaging apps (like Facebook, Twitter, Tumblr, Snapchat, and others). These block lists are hosted over on GitHub at https://github.com/crpietschmann/pi-hole-blocklist You can use these lists to help block the use of these social media and messaging apps / services. There is an individual blocklist available in the project for each service, including a set of combined all.txt
blocklist files that combine multiple of the lists together to make it easier to pull them all in to your Pi Hole setup.
Here are a few of the specific block lists I have included in this project for some specific social media and messaging services:
TikTok blocklist
https://raw.githubusercontent.com/crpietschmann/pi-hole-blocklist/main/social-media/blocklist-social-tiktok.txt
Facebook blocklist
https://raw.githubusercontent.com/crpietschmann/pi-hole-blocklist/main/social-media/blocklist-social-facebook.txt
Snapchat blocklist
https://raw.githubusercontent.com/crpietschmann/pi-hole-blocklist/main/social-media/blocklist-social-snapchat.txt
Instagram blocklist
https://raw.githubusercontent.com/crpietschmann/pi-hole-blocklist/main/social-media/blocklist-social-instagram.txt
Twitter blocklist
https://raw.githubusercontent.com/crpietschmann/pi-hole-blocklist/main/social-media/blocklist-social-twitter.txt
Whatsapp blocklist
https://raw.githubusercontent.com/crpietschmann/pi-hole-blocklist/main/messaging/blocklist-messaging-whatsapp.txt
The above is not a full list of social media and messaging service blocklists added to the project. For the full list, please go visit the crpietschmann/pi-hole-blocklist project directly. Also, I will try to add to these blocklist files in traditional open source fashion, so please feel free to submit a pull request to help ad to them.
Update Pi-hole
Over time, there will be updates and fixes released for the Pi-hole software. It’s important with Pi-hole, as with all software, that you periodically install all updates. By installing updates this will ensure you get bug fixes, and any fixes for security vulnerabilities to keep you Pi-hole secure and up-to-date. Additionally, when new features are added over time to the Pi-hole software, updating will ensure you get access to those as well.
To update the Pi-hole, simply connect to the Pi-hole server over SSH, then run the following command:
pihole -up

Also, if you wish to check for available updates, but want to review them before applying them, then run the following command which will simply output the available updates for you and then exit before applying them:
pihole -up --check-only

Wrap Up
Pi-hole is great ad helping block ads, as the main reason most people use it. However, it can also be used to block any other websites desired, such as those that are NSFW (not safe for work) or even NSFF (not safe for family) too. Also, as a DNS server on your network with the web based dashboard interface, it provides additional capabilities to be able to have some insights into what sites and domains are being accessed from devices on your network. You can use this to help keep your devices, your network, and your business or family safe and secure online.
Happy home (or small business) networking!
Hi Chris. Thank you for the informative article. I’ve been running Pi-Hole for a few years now but learned a few things from this. I was curious, one of our remote office sites is on a CradlePoint/Verizon ISP that has bandwidth caps. There are only a few users but Windows 10 is constantly burning through data. I’ve turned off what I can from a GPO perspective. Do you happen to know of any block lists that control/limit all the data Windows 10 is sending to Microsoft? When I use the Data Usage option in Windows 10, System is the highest data usage every day. Thank you again!
I don’t know / have a list that blocks Microsoft DNS names for Windows Update and other stuff. However, you could also go into the network settings of your Windows 10 PCs and set the connections to be “Metered”, as this will tell Windows not to use tons of bandwidth on the network connection. This is a feature that helps with reducing bandwidth usage by Windows when connected to a mobile hotspot or smartphone, and this could help you in this case. Otherwise, try to look at your Pi-hole query log and block URls that look to be what you’re after and see if that helps.
Hi Chris. Thanks for the response. Metered doesn’t work as it causes Outlook to go offline which we need. I’ll keep digging and see what other tweaks can be made. Thank you!
Thank you for the blocklists. BTW, with a Pi-Zero creating a wpa_supplicant.conf file will allow access via wifi, thus eliminating the need for ethernet hardware.
Is it possible to apply a blocklist to a specific ip or MAC address on my network, say my son’s chromebook, while not impacting mine?
I don’t think this is something Pihole supports. However, you could configure your computers network card to use a different DNS server and just bypass the Pihole altogether on just your own PC. Psst… don’t tell your son how to to this.
I love Pihole, I once installed it on the cheapest Azure Ubuntu VM linked a Public IP and opened port 53. Then I installed an app on my phone that makes a VPN tunnel to itself and set the DNS server to my public facing Pihole. The result was that on every network where my phone connected the ads were removed.