How to Set up Pi-hole on Raspberry Pi 4?.
We all hate ads, but ads are the main source of income for most websites. Personally, I have no problem with advertising, as long as it is not intrusive. This is why there are products like Adblock Plus and Ublock Origin, but what about other devices? Use Pi-hole, a networked ad blocker that lets you filter ads from your entire network with the click of a button. Let’s set it up for the new Raspberry Pi 4.
Pi-hole is a simple server that sits between your router and connected devices and filters ads. It works like this: the router receives all requests from the devices and instead of directing them to the Internet, the requests are sent to the Raspberry Pi, and the Pinhole then culls ads and immediately blocks them. All other requests are then sent to the Internet. Not only can you block ads on every device on the network, but you can also restrict access to certain websites on your network and make the network faster. Simple enough?
Also Read :Â Ten most useful Raspberry Pi commands
1. Install a Pi-hole
Pi-hole runs on a variety of devices and different operating systems, including Raspbian, Fedora, Debian, Ubuntu, and CentOS. You can also put it in Docker and run it on Windows and Mac. In this article, I will focus on installing this on a Raspberry Pi because it is relatively cheaper than allocating an entire machine to just one program and is fun to work with.
I am assuming you have a quick understanding of what a Raspberry Pi is and have one installed and running Raspbian OS. Even if you don’t, installing Raspbian on a Raspberry Pi is very simple: flash the Raspbian image to an SD card using Etcher, plug it into the Pi, and you have a working Raspberry Pi. You can read more about this here.
To get started, open a terminal window on your Raspberry Pi and enter the following command. curl -sSL https://install.pi-hole.net | flap
The installation process will begin, which may take a few minutes, so have a seat. It will start by updating the Raspberry Pi itself and then move on to installing Pi-hole.
You just need to follow the instructions on the screen to install Pi-hole on your computer. Select the default settings and wait for the setup to complete. Just make a note of the IP address and password that you set for Pi-hole, we will need them later.
We’ll assign a static IP address to the Raspberry Pi to make sure the peer hole works even after restarting the router. The setup will do this automatically, however it would be advisable that you manually install it on your router. You can follow the guide here or search the web for how to assign a static IP address to the Rpi.
Now the Pi-hole server is up and running on the raspberry pi, we can log into the control panel to make the final changes. Open a web browser, type “https: //pi.hole/admin/” into the address bar and press Enter. Log into the console with the password that you set during the installation process. If you don’t remember the password, you can easily change it in the terminal window with the following code.
sudo pihole -a -p
Configure other devices
Note that Pi-hole does not actually block traffic, it just assigns invalid DNS advertisements, so requests never reach their destination. For the installation to go smoothly, we need to change the DNS on all devices, including the router. I will list the steps for Android, iOS, Mac, Windows and your router.
2. Change the DNS on the router
Open the router settings by entering the IP address into the address bar of your web browser. This is usually 192.168.1.1, but check the back of your router to be sure. Go to your DHCP server settings, find the DNS server section and replace the DNS record with the IP address of your Raspberry Pi. You will have to remove all other DNS servers from the list or Pi-hole will not work. Save changes and restart. To keep things simple, you can follow this detailed guide to change DNS on each device.
3. Change DNS on Windows
Open network settings on your Windows PC and make sure it is connected to your router. To change the DNS server on your computer, follow these steps.
Start Control Panel Network and Internet Network and Sharing Center Under Active Networks select your Wi-Fi connection Properties IPv4 Properties Change the DNS record to Pi-hole’s IP address.
4. Change DNS on Android
Make sure your Android smartphone is connected to the router’s Wi-Fi hotspot. Follow these steps to change DNS on your Android smartphone.
Settings Networdk and Internet Wi-Fi Click the Settings button next to the Wi-Fi name click the Edit button at the top Click IP Settings Select Static enter the IP address for the device, router gateway and DNS servers.
Also, make sure you don’t leave any DNS records blank, otherwise your smartphone will automatically redirect requests to Google DNS.
5. Change DNS on iOS
Just like on an Android smartphone, changing the DNS server on iOS is simple and similar in steps. You don’t even need to assign a static IP address to the iPhone. Follow the commands below to configure DNS.
Settings WiF i Tap “Wi-Fi Name” Tap “Configure DNS” “Manual” “Enter Pihole DNS” “Save”.
6. Change DNS on Mac
To change DNS on Mac, open System Preferences. Press CMD + SPACEBAR to bring up the Spotlight Search, type System Preferences and press Enter for the result. Find the network in the options and double click to open the network settings.
You will see the DNS Server to edit the record. Click the lock button in the lower left corner of the window. It will ask for your credentials, enter the correct information and click “Advanced”.
Click DNS and click the + button to add a DNS record. Enter Pihole’s IP address and click OK. Your Pihole DNS is now set up on your Mac.
7. Change upstream DNS in Pihole Console
This is the last step. We need to change the record of the upstream DNS server in the Pihole console so that it redirects requests to the router correctly. Open the Pihole Admin Console by typing the following in the URL “https: //pi.hole/admin/”. Log in, click on “Settings” and go to the “DNS” tab.
On this tab, uncheck any DNS server that can be enabled on the left. Check the “Custom 1 (IPv4)†checkbox and enter the gateway address of your Wi-Fi router. Click “Save” and you will see Pihole is active.
8. Use Pihole
You can track all ads you blocked, requests that are allowed on the blank dashboard. It also allows you to manually block websites, so it can be more than just a website blocker. Blocking websites will only work if DNS is configured on the client device, which can be great if you have kids at home. You can control all devices, enable or disable ad blocking for each device, and speed up your entire network.
Final Words
This was a detailed guide to installing Pihole on a Raspberry Pi. It works really well and blocks ads on the web instantly. A few advertisements are skipped here and there, but you can always manually block or enable them. Give it a try and let me know if you run into problems in the comments below.
How to Find Your Raspberry Pi’s IP Address?