Block URLs in a network with automation

Hello all.

Wondering if anyone has a technique for blocking a URL with an automation?

I have a Ubiquiti router that doesn’t have such features and I’ve used PiHole in the past, which seemed to be all or nothing, (I think they no longer support lists either?) and I’m not sure if either would have such a granular API to automate anyway.

Is there any easy way to run a command line that does something with dnsmasq or whatever? If you have a method for this would love to hear about it.

B

Which Ubiquity router doesn’t allow you to block URLs?

I have two methods that I use: This one is on the USG (should also apply to a UDM/UDM-PRO as well) itself: https://community.ui.com/questions/HowTo-Ad-blocking-using-dnsmasq-d-instead-of-etc-hosts/1598a96d-28af-4f3f-ab96-97bccdb897b3

The other method is using Pi-hole (yes, they still support lists). It’s been moved to Group Management though:
image

For automating it, an easy way to do it is with a command-line sensor (Command Line - Home Assistant) and issuing a ssh command to your pi-hole: 'ssh pi@[your-pi-hole] -e "pihole -b [domain you want to block]"'

There is also a pi-hole REST API that you can use to add/remove domains from both the black and white lists (http://[your-pi-hole]/api.php?list=black|white&add=[domain-to-block]|remote=[domain-to-remove]). You can trigger these with a REST sensor in HA.

1 Like

Thanks. I have scoured the UI group and found approaches such as you linked. I don’t consider that a feature of the USG though, it’s a custom script. Unifi is weak in the area of parental controls and their forum shows folks wishlisting it continuously. They have not prioritized it though they aggressively position as “prosumer” products.

Thanks for the information about PiHole lists. I might go back to that but it’s another thing to fail, I’ll look into the script you linked and cmd automations in HA.

1 Like

I feel your pain. Welcome to the [un]wonderful world of Ubiquity. They never listen to the customers. There are features that people have been asking for that are years old now that Unifi has never worked on. For instance, IGMP-PROXY support in the UI (controller or otherwise). Or something dead simple as DNS hostname editing in the controller. We seriously cannot edit /etc/hosts in the UI.

To be honest, my main pi-hole instance (I run two as a primary DNS and secondary DNS pair) have never gone down. They are both running on rPi4s, but they started out on rPi2s years ago. Same lists, same functions, same everything for the past 3 or 4 years now at least. Even the same SD cards.

Honestly my issue with Ubiquiti is that, in my personal experience, the wifi is weak. I won’t bore this forum with all of my bad experiences, but it’s a $2000 unreliable and slow system. But, … I’m too deep to trash it all and get a normal router. Suffering from the sunk cost fallacy :slight_smile:

1 Like

I never had pi-hole drop out either, but the internet (and the family) complains too much when you block ads these days, so for the purpose of blocking youtube/roblox during “school” hours it’s overkill and I don’t need another container to manage if I don’t have to.

1 Like