Google Assistant and Porn Blocking on Raspberry Pi

Using a Raspberry Pi running Pi-Hole, we can block all ads and porn from our home network....

10 months ago

Latest Post This blue llama by Jim Christian

I have a few Raspberry Pi boxes and projects kicking around the house and office. One of the most unassuming is my Google AIY Voice Box, which sits quietly behind me in the office.

The AIY Voice Kit came free with the physical copy of The MagPi 57 last year and I was lucky enough to find a copy. I had a spare Raspberry Pi 3 B kicking around that I had originally thought to run RetroPie on, but changed my mind when the opportunity to build my own Google Assistant came up instead.

You can check out the Voice Kit details and hardware layout here. It was a couple hours build, around visitors from out of town and a trip to see the Moomins at Kew Gardens with the kids. Tanooki and a friend watched on while all the bits and pieces were put into place.

The arcade button is a great addition to the AIY kit. I can hardly tolerate using “Hey Siri” on the iPad, and am not keen on omni-present, ever-listening devices in my home (for good reason), so if I want to use the AIY kit, I have to push the button on top. The pulsing glow of the button also gives a really cool feel to the atmosphere and acts as an ambient indicator that the box is active.

Using Google Assistant

Tanooki and I have discovered some really fun things to do with the Google Assistant. First and foremost when he was learning to talk and ask questions we would take turns asking questions like:

“What sound does an elephant make?”

“What sound does an ambulance make?”

And so on. Not only did it help teaching him a little patience, having to push the button, wait and then ask the question, it also helped teach him to slow down his words and try to speak more clearly to make sure that Google Assistant understood him. As it happens, Google Assistant understood him a lot better than it understood me, most times! So perhaps it is myself that needs a little more diction practice.

One caveat is that Google Assistant still hasn’t updated its joke response to permutations of “What does a fox sound like?” C’mon, Google, it’s been five years already!

We've also used Google Assistant to ask it to tell us ‘knock knock’ jokes on evenings when we're looking for something fun to do. It's fun to watch a 3/4 year old process these and also try to come up with his own as a result.

Sometimes I use it to check the weather or to get a daily agenda, but I don’t really trend towards using voice-assist technologies like that. So for the moment, the Assistant is a novelty until I explore some further integration possibilities.

PiHole

By far, however, the most useful purpose for having a Raspberry Pi always online in my office is to run Pi-Hole - the open source “black hole” for internet advertisers.

It’s a one-line install on the Raspberry Pi, and it allows me to route all my home network’s internet traffic through it so that we don’t get ads when using the internet. We don't use the internet that much “out in the open” as a family anyway, and Tanooki knows not to click on ads anyway, but you can never be sure what kind of advertising content is going to come up. Some mornings we read the news together, although this is often in the form of Apps and aggregators such as Feedly and Apple News, so much is already stripped down. Clicking though to a site to read the full article on some sites may show completely unrelated sidebar ads that I don't want him to see.

The Pi-Hole gets over this as every device in my house has to go through it to get out to the internet. So, no ads are displayed on any over our devices, and I don't have to managed it at a ‘per-device’ level.

When I first let Tanooki play on a Raspberry Pi computer while I was in my office, he was around two years old. Within five minutes he had clicked on to a browser, and within two clicks of typing in random gibberish, he had gotten through to some tremendously inappropriate content.

It was then that I decided to see if I could use the Pi-Hole to also block porn - and it turns out it’s really easy to do this too. There’s a series of community maintained blocklists, where you can select lists around curated categories such as ransomware, cryptocurrency, etc. Your mileage may vary though, and you should check regularly that the correct sites are being blocked. For instance, I noticed during testing that some porn domains still resolved on my network so I had to manually add them to the blacklist (not to be confused with blacklist). Kind of like a manual override. It’s important to schedule in some upkeep time on your home network, say half a day per month, if you’re not already.

To do this, I had to upgrade my home router from what was supplied from Virgin Media, as their boxes are very simple and don’t allow real configuration. So I run a NetGear Nighthawk R7000, which lets me point my DNS server to another device on my network - in this case, the Raspberry Pi running Pi-Hole.

So devices connected to my network connect straight to my wireless router (the R700), and the router then forwards any traffic requests to the Pi-Hole. The Pi-Hole checks the blocklists, blacklists and whitelists and allows traffic through or blocks it accordingly. I have found that you need to be selective with the block lists you add, and not add too many, as this could give your Raspberry Pi too much time have to “think about”. In a couple of instances, I've completely overloaded it and had to strip some lists away. You may also have to add whitelists to counter any aggressive blacklisting to make sure that your traffic goes through correctly.

Tanooki was able to find YouTube videos related to Super Mario 3 on his Kano independently most recently. So while that prompted a talk with him about not looking for images or videos without Mama or Papa helping, I’ve also made amendments to the DNS service settings to force Google Safe Search and YouTube restricted mode.

All queries through the Pi-Hole get logged, so you can run checks, or see at a glance what’s been accessed, just in terms of raw domains.

What’s nice is that I don’t have to bloat my network devices to run AdBlockers, which sometimes can interfere with my web development work. If I ever need to break out of the network, I can simply change the DNS on my device to something like Google (8.8.8.8, 8.8.4.4), or activate the VPN. On my Mac Mini, I have a Keyboard Maestro Macro set up for that.

On occasion, the Raspberry Pi might freeze up, which means that it can’t process any DNS requests and nobody will be able to access the internet from within the house. When this happens, I can connect back into the router and set the DNS servers back to Virgin Media’s defaults so that everyone can carry on surfing while I get a monitor up and troubleshoot.

For a £25 computer though, that’s not bad going, being able to run Google Assistant and an advertising blocker / internet filter for the entire network at the same time.

Jim Christian

Published 10 months ago