In this Raspberry tutorial, we will be setting up a network-wide ad blocker called Pi-hole. Pi-hole works by acting as your DNS server and blocking domain names.
What Pi-hole does is act as your DNS server. Your computers and routers will connect to it for DNS requests.
These DNS requests will then be filtered by the Raspberry Pi.
Any DNS requests that match any that match a known ad host will be rejected meaning the connection will never meet your computer. Therefore the ad will never be loaded by the devices.
Network-wide adblocking is a useful tool for stopping ads from appearing on devices that don’t have any easy to use adblock tool.
It’s also a handy way to improve your network performance and bandwidth usage as the number of files downloaded during normal web browsing will be reduced.
It also has the added side effect of potentially improving the security and the privacy of your network, as some sites use relatively dodgy ad providers.
You can install the Pi-hole on other operating systems other than Raspbian. They have support for Ubuntu, Debian, Fedora, and CentOS 7 (Non-ARM).
If you decide to use the network-wide adblocker, please consider subscribing to our ad-free service to help support the site and allow us to continually grow.
Below are all the pieces of equipment that I made use of for this Raspberry Pi Pi-hole tutorial.
Installing Pi-Hole on to the Rasbperry Pi
1. To set up our network-wide adblocker, we are going to utilize a piece of software called Pi-hole.
Pi-Hole is the software package that will be handling everything for us. It sets up and configures a DNS server that can be configured to whitelist and block individual domain names.
It also provides a fancy web frontend to the whole system. This frontend allows you to see the statistics in real-time and make changes to the Pi-hole configuration. This includes the ability to whitelist or blacklist specific URLs.
The Pi-hole install script automatically installs the Lighttpd web server. You don’t have to worry about setting your own up beforehand.
We can run this single command to download and run the Pi-hole install script.
curl -sSL https://install.pi-hole.net | sudo bash
While we know Pi-hole is safe, if you want to check the script that we will be running yourself, go to the Pi-hole install domain in your web browser.
2. Once you have run the command, it will download and run the script that begins setting up your device for Pi-hole.
A few of the tasks it does are verifying the amount of available free disk space, updating the package list, and several other things.
3. The first screen informs you that you are about to transform your Raspberry Pi into a network-wide adblocker.
Press the ENTER key to continue to the next screen.
4. You will be informed that you can donate to help with the development of Pi-Hole.
If you would like to help the team out, follow the link shown within this step.
Press the ENTER key to continue with the setup process.
5. Next, is a screen informing you that you must have a static IP address.
The installation script will handle this process for you. However, it is best to set the IP through your router using DHCP reservation as well.
Continue to the first set up steps by pressing ENTER.
6. You can now choose an upstream DNS provider for PiHole to use.
Whenever Pi-hole has a request that isn’t cached or blocked, it will contact the upstream provider for the IP address.
For our tutorial, we will be using
Cloudflare as our DNS provider.
You can select your option by using the ARROW keys. Once chosen, press the ENTER key.
7. Here we can deselect some of the third party lists that will be enabled by default.
These lists are used by Pi-hole to know what domains it should block from loading.
Use the ARROW keys and SPACEBAR to select or deselect a list.
Once you are happy with the selected lists, you can press the ENTER key to continue.
8. Now we have to select the protocols we want to utilize.
Unless you have a reason, you don’t want to block ads over a particular protocol, leave these options.
Press the ENTER key to continue.
9. You will now be asked if the current network settings are fine to use for the static IP address setup.
You can see the IP address that it will use on this screen (1.).
If you are happy with the settings, select
<Yes>, then press the ENTER key.
10. You will now be warned that there is a chance the router will assign this IP address to another device.
However, most routers will try and avoid this from becoming a problem. To completely solve this problem, you will need to use DHCP reservation as well.
Press the ENTER key to continue.
11. You will now be asked if you want to set up the Pi-hole web admin interface on your Raspberry Pi.
We recommend installing the web interface as it gives you access to an easy way to configure Pi-hole and check on statistics.
Use the ARROW keys, and SPACEBAR to select the option you want.
Once selected, press the ENTER key to continue.
12. You will now be prompted if you want to install the Lighttpd web server.
Unless you have a web server installed that you want to use, select the
Once selected, press the ENTER key.
13. Now you will be asked if you want to log the DNS queries.
We recommend that you leave this switched to “
On” as it allows you to keep track of the domain names loaded and have some neat statistics.
Press the ENTER key to continue with the installation.
14. We can configure the level of privacy we want our Pi-hole DNS server to have.
For our guide, we will be sticking with “
0 Show everything“. This setting allows us to retain the most statistics.
Use the ARROW keys, and SPACEBAR to select your privacy setting. Once set, press the ENTER key.
15. Installation of the Pi-hole server on your Raspberry Pi has now completed.
This screen will tell you how you can gain access to the Pi-hole web interface (1.).
As well as show you the password that you need to use to log in to the admin account (2.).
A Quick Look into the Pi-hole Web Interface
1. To get to The Raspberry Pi Pi-hole web interface, all we need to do is go to the following web address in your favorite web browser.
Make sure you swap out
192.168.1.105 with the IP address that was displayed in the last step of the previous section.
2. You will be greeted with the following screen, at the moment this will not show any real stats as we haven’t hooked it up to anything.
For now, let’s just go straight to the Login page, you can find this by clicking “
Login” in the sidebar.
3. On here you need to enter the password that you got at the end of the installation of Pi-hole to log in.
4. You will now be presented with the admin dashboard.
This dashboard is just like the normal one with a couple more graphs and access to all of the configuration pages.
Below we will go through some of the pages that are available within the Pi-hole interface.
- Query Log – The query log shows all the most recent queries that have been made to the DNS server. It is an easy way to find a recent address that may have been loaded and blacklist them.
- Whitelist – This screen allows you to add certain domain names to Pi-hole’s whitelist. This whitelist means those websites will no longer be blocked by the DNS server. However, if that domain is blocked by a wildcard, then it will continue to be blocked.
- Blacklist – This screen allows you to add certain domain names into Pi-hole’s blacklist, this means those websites will be blocked by the DNS server.
- Disable – These options allow you to temporarily or permanently disable the blocking functionality of Pi-hole, it will continue to function as a normal DNS server while disabled but will no longer block DNS requests.
- Update Lists -This tool allows you to trigger an update of the ad blocking lists, it is useful for ensuring you are running the latest versions of the ad block lists.
- Query Adlists – This tool allows you to find out if a certain URL is being included in the ad blocking lists, it is useful for checking why a certain URL might be getting blocked.
- Tail pihole.log – This tool shows the last lines of the
pihole.logfile and continually updates live, this is useful for checking to see what Pi-hole is doing to requests.
- Settings – This section contains some configurable settings, this allows you to change the way your DNS works, what upstream DNS providers you want to use among several other options. You can even enable DNSSEC in the options.
For the average user, you will not need to change these options unless you made a mistake in the initial installation.
Connecting your Network to the Raspberry Pi Pi-hole
There are two different methods for setting up the network-wide ad-blocker on your network.
The first of these two options is the easiest and will extend the Pi-hole coverage to all your devices.
This option is to change your router’s DNS settings to point towards the Raspberry Pi. We recommend this for setting up the network-wide adblocker.
The second is to set the DNS setting for each of your devices. This method is more challenging to set up and something you must do every time you add a new device to your network.
However, it can be useful if you only want specific devices running through the adblocker.
Setting Routers DNS Settings
Changing the DNS settings is different for every router, but we will go through the steps we used for our router. First, we need to go to the router’s admin page, most routers reside on the http://192.168.1.1 local IP address.
If you are asked for a username and password but are unsure of what it is, then try using admin for the username and admin for the password.
Once you are logged in, look for anything mentioning
DNS server, or
TD-W8960N router, these resided under “
Advanced Setup” then under “
DNS” then “
Within this screen, set the primary DNS server to the IP address of your Raspberry Pi, for example, mine is
Make sure it is the only DNS server that is set, as it handles all upstream DNS services itself, and adding alternatives could break the functionality of the adblocker.
Windows DNS Settings
Below are the steps to changing the DNS settings on your Windows device to point to your Pi-hole.
DNS settings are specified in the TCP/IP Properties window for the selected network connection.
1. Go to the Control Panel
2. Within the control panel, click the
Network and Internet option.
3. Now click
Network and Sharing Center.
4. Within this center, click the
Change adapter settings option in the sidebar.
5. In this network page, double-click the network connection that you want to configure.
6. Within the connection properties, you will need to find the connection type.
Make sure you select IPv4 or IPv6, depending on what you are using (1.).
Once you have one selected, click the
Properties button (2.).
7. Within the properties page, there are a couple of things you will need to do.
The first is you need to click the “
Use the following DNS server Address” radio button (1.).
You will need to enter the IP address of your Pi-hole device in the
Preferred DNS server textbox (2.).
With everything set, click the “
8. Repeat the procedure for additional network connections you want to change.
Linux DNS Settings
In most modern Linux distributions, DNS settings are configured through Network Manager.
1. Click System > Preferences > Network Connections
2. Select the connection for which you want to configure
3. Click Edit
4. Select the IPv4 Settings or IPv6 Settings tab
5. If the selected method is Automatic (DHCP), open the drop-down and select Automatic (DHCP) addresses only instead. If the method is set to something else, do not change it.
6. In the DNS servers field, enter your Pi’s IP address
7. Click Apply to save the change
8. Repeat the procedure for additional network connections you want to change.
9. If your distribution doesn’t use Network Manager, your DNS settings are specified in /etc/resolv.conf.
Mac OS X DNS Settings
1. Click Apple > System Preferences > Network
2. Highlight the connection for which you want to configure DNS
3. Click Advanced
4. Select the DNS tab
5. Click + to replace any listed addresses with, or add, your Pi’s IP addresses at the top of the list:
6. Click Apply > OK
iPhone DNS Settings
1. From the iPhone’s home screen, tap Settings.
2. Tap Wi-Fi. The available wireless networks in range of your iPhone should appear.
3. Find your wireless network in the list, and then tap the arrow.
4. Tap the DNS field.
5. Delete the current DNS servers, and enter your Raspberry Pi’s IP Address.
If you love your privacy, then other Pi projects might take your fancy. Something like the VPN access point is great if you want to add an option for people to hook into a VPN by simply joining a WiFi access point.
I hope this Raspberry Pi tutorial on installing Pi-Hole has helped you be successful in your set up on your Pi.
If you have any thoughts, feedback or anything else then be sure to head over to the forums.