You start reading an article only to find the screen go unresponsive as an interstitial ad fades in, blocking your content. Tap the impossibly small dismiss icon to go back to reading your article. Attempt to tap a legitimate link only to find that a new ad loads directly under your finger, sending you off to a random location, possibly to get caught in a loop of "your phone is infected with a virus" phishing attack. "Sponsored content" and clickbait are gentler and more insidious forms of mobile advertising: "You won't believe what this famous actress looks like now!"
"Install an ad blocker," goes the rallying cry. In my household, we have 5 laptop computers, 2 iPods, 3 iPhones, 2 Android phones, 2 Android tablets, 1 iPad, and 3 Kindles. Each of these devices has multiple ad-serving platforms. A mobile phone, for example, has 1 or 2 commonly used web browsers along with dozens of apps that also serve advertising. Installing, configuring, and updating ad blockers for all those access methods on all those devices doesn't sound like a fun task.
Instead of blocking ads in an app or browser, a more robust solution is to block requests for ads from ever leaving your home network. When you view a page in your browser of choice, the browser is tasked with interpreting the layout of the page to display what you see, including downloading all resources referenced in the page (e.g. images, scripts, and ads). Some of these are downloaded serially during loading, and some are downloaded as you scroll through pages. This is why pages jump as you view them: content is being displayed as it's downloaded, causing you to tap in all the wrong places. If you can isolate those requests to ad networks and block them, you should be able to view all of the good content, without seeing the ads. That requires a mechanism to sit between you and the network to intercept those requests, and a way to inspect the requests and only block the bad ones. That's the objective of this project.
This approach isn't without issues, however. There are many legitimate reasons why you might want to permit these outbound requests. The biggest one is that ads support the businesses and publications you love. For many apps and online publications, ads are what keep the lights on and the doors open. If you like the content supplied by an online publication, you absolutely want them to deliver ads to you. That's your patronage in return for what they provide to you. Some apps offer a great experience and feature reasonable, unobtrusive ads. By all means, support the developers and permit their ads. Clearly, there are reasons why you might want to allow some ads through your defenses.
This project uses a newer-model Raspberry Pi along with Pi-hole software to create a network-wide filter to suppress ads at the source.
Raspbian is the Raspberry Pi Foundation's officially supported operating system. There are plenty of other distributions you can use, but Raspbian is well supported, updated frequently, and contains many additional tools to make your Pi experience smooth.
While you're here, you should update a few settings to make your Pi a little more usable.
Begin the installation by opening the Pi console. It's the icon in the upper left that looks like a greater than sign followed by an underscore. Enter the below command:
curl -L https://install.pi-hole.net | bash
If you're worried about piping anything to your bash, you can view the contents of the file before installing it. Enter the below lines in turn: the first downloads the target file, the second opens it for viewing, the third grants execution privileges, and the final performs the install.
wget -O basic-install.sh https://install.pi-hole.net
nano basic-install.sh
chmod +x basic-install.sh
./basic-install.sh
Installation will take several minutes as all required components are added to your Pi. When the system is ready to proceed, the "Pi-hole automated installer" dialog will display. When working through these dialogs, use your spacebar to select/deselect whatever is under the cursor, and use the enter key to accept the selection. After advancing through a few informational screens (see gallery for the sequence), you'll be asked to make some choices. Here are the important ones:
Once you enter the above and confirm that you'd like to proceed, the Pi-hole installation will complete. You can shutdown your Pi and prepare to move it to your router, if you're not nearby already.
I'm using a Google OnHub router, so my settings will not look like yours, but the procedure is the same for most routers.
Once Pi-hole is installed and running, you will have access to an administrative panel where you can monitor what the Pi-hole is doing for you. You can find this panel at http://192.168.86.xx/admin/index.php, replacing the "xx" with the number specific to your network.
You might as well also test your SSH connection before you get too comfortable. If you don't have it, download Putty, open it and point it to your Pi's IP address. You'll be prompted to login: use "pi" as the username, and enter the password that you configured earlier. If you didn't change your default password (shame on you), enter "raspberry"as the password.
The latest update to Pi-hole added an improved administrative interface. Staying up-to-date is simple: login to your Pi via SSH, and enter the below on the command line:
pihole -up
It should have the opposite effect. It's not blocking inbound ad pushes, it's blocking outbound requests for them. So it should result in less for your browser or app to load, which translates to faster loading of content and less bandwidth usage. As an added bonus, if you're using a mobile device, this should have the benefit of preserving your battery. Additionally, it caches DNS queries, which makes your lookups faster for those locations you visit or request more than once.
The Pi-hole will send thousands of DNS requests a day, but they are very tiny, so the traffic shouldn't even be noticeable. You should be able to easily share even the slowest of broadband connections with an entire house filled with guests. And those thousands of requests will likely be more than offset from the ads that you won't be downloading.
It might. For the Android apps I've built that serve responsible ads, I wait for a response back from the app before I proceed. Other apps built like this will get stuck waiting for the response. There are also some cases where a server on the blacklist might serve up legitimate content, in addition to ads. This content could be blocked. If you're using any referral or cashback sites, the Pi-hole could interfere with them. Finally, it could impact streaming services you use. That said, there is a mechanism around this: the whitelist.
On the left-hand side of the Pi-hole admin panel (http://192.168.86.xx/admin/index.php), click the "Whitelist" link, and add the domain you would like to bypass the Pi-hole. You might need to view the "Query Log" (also in the menu) to make sure you whitelist related domains serving content on behalf of your targeted domain.
Ihave heard there are troubles of more than one kind. Some come from ahead, and some come from behind. But I've brought a big bat. I'm all ready, you see. Now my troubles are going to have troubles with me!
- Dr. Seuss
Hi, Shaun here. No, not the soccer player. And not the children's performer. Just me, a 40-something father of two, residing in Raleigh, NC, where the summer heat has me questioning my life choices.
I try lots of things. I'm okay at some of them. My hobby is collecting hobbies. I drink a lot of coffee. I'm susceptible to ear worms. I throw myself into the things I love. I can't wait for the weekend.