Advertisements have been a real pain for content consumption on the internet nowadays. So before going any further into the thing lets understand how these ads work. First there are advertisement servers from the advertisements shown in our devices. Our DNS server redirects us to these servers. Now a DNS also known as Domain Name Server, is a server which knows the URL of the IP of a server. Clearing these out, what happens when an advertisement is redirected to us, is if the DNS server does not know the ad server there will be no way that that ads will be shown in our devices. So I will be showing how this can be done and make a network-wide ad-blocker for a home/office environment. For this you’ll require a computer,(it can be an old pc, a docker container on a homelab server, a virtual machine on a computer) but I’ll show how this can be done on a low powered single board computer known as Raspberry Pi. Raspberry Pi’s are very popular with DIY hobbyists to IOT specialists and even meeting Industrial Automation needs. This barebone computer comes with a powerful ARM processor to run lightweight linux distributions based on ARM architecture. There are many versions of Raspberry Pi, I’m using the latest Raspberry Pi 4 with 4 GB of LPDDR4 memory, which I bought for some home automation projects.So let us get on the steps real quick.
Things Required:
- Raspberry Pi with an adapter to power it on
- A Memory Card and a Memory Card Reader
- A Computer
Network Structure:
Step 1: Setting up the Pi
Getting all these straight, First we will plug download the latest version of raspbian(a custom Linux OS for Raspberry Pi built by the sweet folks at Raspberry). I prefer the Raspbian Lite, as it is only a command line centric version of raspbian it’ll use less hardware resources on the Pi.
After this we’ll download Raspberry Pi SD card Imager from raspberry pi’s official website and install it on our computer(available for Linux, Mac and also Windows). For ease of access we’ll make the pi headless, for this we will enable ssh for remote access to the pi and connect it to the network. We can connect the pi using 2 methods, ie. using a network cable or Wi-Fi. Using an ethernet cable is pretty straightforward, so I'll show how to do this using a Wi-Fi network. So we will remount the SD card in the computer and create an empty file naming SSH and make another file wpa_supplicacant.conf containing the Wi-Fi credentials. Now we will power on the pi.
Step 2: Setting up Adblocker
At this moment we can access the pi using a ssh. For that we’ll be going to need the ip of the raspberry pi. We can find it out by logging into our router and finding the ip. After this we’ll open the terminal and type “ssh pi@192.168.1.100” and enter the password “raspberry” to login. First Step is changing the default password of login by typing “sudo raspi-config”. Now we will use pihole to easily block advertisements. Now we will run “curl -sSL https://install.pi-hole.net | bash” in the terminal and wait until everything is completed. Now in your browser type the ip address of your pi followed by “/admin” and access the dashboard.
Step 3: Adding Pi as your network DNS server
Now open the admin page of your router and login in your router. Now open your Routing Details where you will find the option to add a custom DNS server(Google how to open DNS settings on your router as for different routers the settings are different).
You will certainly see that all the advertisement disappeared from your home network.
Advantages of using network-wide adblock:
1)Easy to set up for a wide array of devices.
2)Whitelist only useful services for IOT and Smart home devices.
3)No advertisement on Internet Enabled Smart TV.
4)Pretty cheap solution for network monitoring and setup firewall rules.
2)Whitelist only useful services for IOT and Smart home devices.
3)No advertisement on Internet Enabled Smart TV.
4)Pretty cheap solution for network monitoring and setup firewall rules.
Here is the video I made for easy setup for the Raspberry Pi:
https://youtu.be/_ECU66wdgTk
If you face any problem setting it up, or have any suggestion please comment below.
Have a great day! By: Sayan Chakraborty
https://youtu.be/_ECU66wdgTk
If you face any problem setting it up, or have any suggestion please comment below.
Have a great day! By: Sayan Chakraborty
0 Comments