
Block ads for all devices inside your network with the Raspberry Pi
Introduction:
If you are looking to do some interesting projects on Raspberry Pi then Pi-hole will be best to play with.
In this blog we will install Pi-hole on a Raspberry Pi to block all the ads(advertisement) which you get on your devices such as phones laptop etc. Now you will have a question what is Pi-hole and why it’s needed?
Pi-hole is a network wide ad blocking which act as DNS sinkhole.
It filter out Ads before they are reaching your device.

Pi-hole offer several advantages such as Network wide protection and Block in app advertisements.
What components do you need?
All you need is:
- A Raspberry Pi (I used Raspberry Pi4 https://www.raspberrypi.org/products/raspberry-pi-4-model-b/ )
- USB type C power supply
- microSD card (32GB is sufficient)
- Network cable (optional if you use Wi-Fi)

Quick Outline of steps as you know we have done the basic How to configure the Raspberry Pi?
Steps needed for Pi-hole:
Install Pi-hole and Configure the DNS and then we can access them through dashboard.
Here we can use PuTTY session to login into Pi.

My IP is 192.168.2.59
If you on different operating system you can directly SSH on them using terminal for example on MAC you can simply open terminal and type this
ssh pi@192.168.2.59 // change IP address according to your setup.
Also we need to set the Pi IP address on static we cannot keep them on DHCP because it will create an issue if IP get change you’ll need to change the DNS server IP every time.
In my case changing the Pi IP to static on my router which is USG 3P.

Once IP is fixed we will use ‘nano’ to edit the DHCP client configuration file on Pi:
sudo nano /etc/dhcpcd.conf

Scroll down to the end of the file and change the lines according to your network setup for static IP
#Example static IP configuration:
interface eth0
static ip_address=192.168.2.59/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.2.1
static domain_name_servers=192.168.2.1 8.8.8.8
Remove the # and to save the changes press ctrl+ X and then press Y click enter settings will be save.
Pi-hole Installation:
After the basic configuration is done now we have to install the Pi-hole software it is simple as we have to execute the following command to download the Pi-hole installation scripts.
curl -sSL https://install.pi-hole.net | bash
After executing the command you should see the following result.

Now during installation step by step you will ask to choose the value you will see a blue screen to choose them.
Here it says it needs a static IP address we have already configured it.

Static IP address
Here it is asking which DNS server Pi-hole should use to resolve IPs/Domains you can choose on the list I’ll select Google.

DNS Provider
As you know Pi-hole relies on lists with unwanted ad domains, we have to use some third party repositories here is a list all are activated by default we can click enter to proceed further.

Blacklist repositories
Now we need to select IP protocols version to block the unwanted ad so we can leave both protocols activated by default.

IP Protocols
The IP Address of Raspberry Pi should be static which you have configured before, the Gateway usually be the IP of your router.

Static IP address
Now we want to install web admin interface to access the dashboard of Pi-hole so we should select yes.

Web Admin Interface
Yes we also want to use the Web server, If we select no we can’t use dashboard.

Web server
Logging queries should be enable so incase if we get some issues we an check on logs.

Logs queries
For privacy mode we can also use the default option to see everything that’s block by Pi-hole on dashboard.

Privacy Mode
This is the important part because it contains the password and also web interface URL address please note it down or take a picture of it.

URL to the dashboard and the login password. Write it down!
After confirming the last screen our installation is completed now.

Completed
Now we can the Pi-hole dashboard on a browser by typing this “http://192.168.2.259/admin” or “http://pi-hole/admin” use the IP address according to your setup.
Note: The domain http://pi-hole/admin only works if you setup pi-hole as your DNS server.
Now last step is to configure the DNS
To configure there are two ways:
First is you can set the Pi-hole IP address as default DNS server on your router in my case I have set them on the WAN settings of USG, Similarly you can try on your different brand of router which you use.
Second ways is to configure Pi-hole IP address as your default DNS provider under your Machine laptop or PC. It is under your ethernet section you can set them under IPV4 sections.
Now you should be able to access the Pi-hole dashboard by using “http://pi.hole/admin”

Dashboard of Pi-hole
You can check various setting as per your need.
I hope you will enjoy this blog related to Pi-hole adblocker on your networks if you have any questions comment on it also show your love.