Unlike many other ad blocking services, that blocks ads on your computer, the Raspberry Pi can do something more, which blocks the ads at the router level, So that there will be no ads on your computer, and also no ads on your smartphone, tablet and any other device on your network. This article will help you to use your Raspberry Pi as a network-wide ad blocker.
How to Use Your Raspberry Pi as a Network-Wide Ad Blocker? | Raspberry Pi Ad Blocker
To block the ads at a router level, we will use Pi-hole, which is a server program. You should install it on Raspbian OS, so you can begin this by installing Raspbian and updating it (sudo apt-get update && sudo apt-get upgrade).
Step 1: Now Launch the Pi-hole installation wizard and enter into the Terminal and enter the following command:
curl -sSL https://install.pi-hole.net | bash
This brings up the installation wizard. The installation wizard shows you that since the Pi-hole is a server, it needs the static IP address. It shows this in ALL CAPS to enlarge it.
Step 2: Now you can choose the interface and configure your static IP settings. Hit okay to get the installation wizard and then choose between the Wi-Fi and Ethernet. Either will work. Once you have clicked the OK for the installation wizard into submission, it will install the packages and let you know when it is complete.
Step 3: Write down the Raspberry Pi’s IPv4 address, When the installation wizard wraps up, you will get the dialogue box titled “Installation Complete!” In that box, you will be your Pi’s IPv4 address. You can write that down along with your password, you will need them in future.
Step 4: Now its time to change your server’s DNS settings. Everything that runs through your Pi-hole server will have ads blocked Now you have to force the device traffic through the server.
This part will vary based on your operating system:
Windows
- Right-click the Start button and then select Network Connections
- Right-click your Wi-Fi network or Ethernet and select Properties
- Double-click the Internet Protocol Version 4 (TCP/IPv4)
- Click Use the following DNS server addresses.
- Now enter the Raspberry Pi’s IP address as your Preferred DNS server.
- Click OK and then, once again, OK.
OS X
- Click the Apple menu and navigate to the System Preferences…>Network>[your network]>Advanced…>DNS
- Now click the plus sign on the left side and then enter your Raspberry Pi’s IP address
- Click OK and then Apply
Android
- Navigate to Settings>Wi-Fi
- Press and hold the current network and then navigate to Modify Network>Show Advanced Options
- Change your IP Settings to Static
- Enter the Raspberry Pi’s IP address under DNS 1
- And tap Save
iOS
- Navigate to Settings>Wi-Fi>[your network]>DNS
- Enter the Raspberry Pi’s IP address.
Once you have done this, you couldn’t see ads anymore.
Step 5: If you want to whitelist some sites, just follow the step below.
To whitelist sites, go to the Pi-hole interface on your browser as you did in Step 3 – though this time you have to log in to the interface using the password that Pi-hole provided.
Now click Whitelist and add sites that you want to whitelist. That’s it you are done.