Transform Your Raspberry Pi into a Network-wide Ad Blocker

7V9R...YaGh
3 Aug 2024
37


Advertisments are everywhere in todays digital landscape, from websites, apps, and even streaming services. Taking matters in own hands by blocking ads and tracking scripts, setting up your own ad blocker with a Raspberry Pi is a great way to start. Appart from the project that will help you manage ads, but it also offers a hands on way to learn about Internet of Things (IoT).

How does it work?

We will use Pi-hole it’s a popular tool that acts as a network-wide ad blocke by functioning as a DNS sinkhole. In a nutshell Pi-hole interecentps DNS requests and blocks these that match known ad and tracking domains.

DNS (Domain Name System): DNS is like the phonebook of the internet. Basically it translates names like www.google.com into IP address 

  • Primary DNS (IPv4): 8.8.8.8
  • Secondary DNS (IPv4): 8.8.4.4


DHCP (Dynamic Host Configuration Protocol): DHCP is a network management protocol to automatically asign IP addresses and other network configurations. 


The diagram bellow hope is clarrifing enough how it will work.


Setting Up Your Raspberry Pi


For the setup, it’s advisable to use Raspberry Pi OS Lite, which is a minimal version of the Raspberry Pi operating system.

  1. Install Raspberry Pi OS Lite and connect your Raspberry Pi to your router.

2 .Set a Static IP Address:

  • SSH into your Raspberry Pi using the command: ssh pi@<your_pi_ip_address>.
  • Edit the DHCP configuration by running sudo nano /etc/dhcpcd.conf.
  • Set your desired static IP address, ensuring it’s within the range provided by your router’s DHCP settings.
  • Save the changes and reboot the Raspberry Pi using sudo reboot.


When connecting on ethernet you wont know your IP address unless search it in router admin LAN devices. 👇


The DHCP configurations better to enable just one as wlan0 is not needed in my case to not cause conflicts.


Installing Pi-Hole


Installing Pi-Hole is straightforward. Simply run the following command in your terminal:

curl -sSL https://install.pi-hole.net | bash


The listed command will start the Pi-hole installatio script. Just follow screen prompts to complete the setup process. For a detailed walkthrough pick up the video listed here at the 4:08 mark.

Important Note on DNS Configuration


After installing Pi-Hole, you may notice that your devices are not immediately routing traffic through it. This is because, by default, devices on your network continue to use the DNS server provided by your router, which is often your ISP’s DNS or a service like Google DNS.
Few things to consider:

  • Delayed Configuration: If your router’s DHCP is set to manual mode (meaning it’s not automatically updating DNS settings), your devices may take some time to start using Pi-Hole as their DNS server. This can be due to DHCP leases needing to expire and refresh with the new DNS settings.
  • Manual DNS Setting: If you don’t want to wait, you can manually configure your devices to use the Pi-Hole as their DNS server. On Windows, for example, you can do this by going to your network settings and entering the IP address of your Raspberry Pi as the DNS server.

Manual setup you can see being done bellow on Windows device same can be done on OS if patience is not your strong suite.


Accessing the Pi-Hole Dashboard


Once everything is set up, you can access the Pi-Hole web interface to manage your network settings and view blocked requests.

http://192.168.1.74/admin/


Raspberry PI while being small can be a powwerfull tool ranging from setting up NAS (Network-Attached Storage) , VPN or even delve into basic electronics projects. These are just a few of many ways to expand your knowledge of IoT (Internet of Things) with this versatile device.

With Pi-Hole running, you should see a significant reduction in ads across your network, and you’ll have greater control over your DNS settings — no need to rely on Google’s or Microsoft’s default configurations.

Write & Read to Earn with BULB

Learn More

Enjoy this blog? Subscribe to Mozes711

1 Comment

B
No comments yet.
Most relevant comments are displayed, so some may have been filtered out.