Live data from Hacker News

Ad blocking with Raspberry Pi and Pi-hole

cri.dev

31–40 of 163 posts

Re: Ad blocking with Raspberry Pi and Pi-hole

#31
post #10

I wish it were more effective in removing Youtube ads on my kids' iPads, but I understand it's a tall order. At least it gets rid of ads in most other apps.

Try Microsoft Edge. Its built in ad blocker works for me with Youtube on my iPhone.

I block ads at the application layer, DNS based ad blocking doesn’t really do it anymore and can create another troubleshooting surface to consider when it breaks something.

Re: Ad blocking with Raspberry Pi and Pi-hole

#32
post #26

Earlier quoted context omitted.

I have an iOS shortcut that hits the disable endpoint, so they have a button on their phone they tap that will disable it for 30 minutes at a time.

Any chance you can share that shortcut? I currently have a bookmark that my roommate can hit, but a shortcut would be better.

I use a modified version of this with hard coded times so there is no user input: https://routinehub.co/shortcut/2904

Re: Ad blocking with Raspberry Pi and Pi-hole

#33

I actually have been doing some work with MaraDNS to have the ability to have a pi-hole sized blacklist. The main source of pi-hole’s blacklist is this Git repo: https://github.com/StevenBlack/hosts That is about 60,000 hosts, so I added MaraDNS support to have up to 500,000 blacklisted names. Since it’s a speed-optimized (not size-optimized) cache, each element takes about a kilobyte of memory, so a blacklist this s…

What is the optimization gained by having 1KB cache slots when the cacheline size on Intel and ARM is typically 64 bytes?

Each cache entry needs a hash bucket so we can look up the entry in O(1), and we need more hash buckets than entries to minimize cache look up time. The hash bucket needs a copy of the element for each hit (to verify we hit the correct hash bucket), and a possible link to the next hash bucket, just in case we got a hash collision (we still need to store that link in memory as a null pointer regardless). [1]

The strings are special structures which allow binary data to be stored in them and to protect against buffer overflow protection, so they take up more room than a normal string.

Since the cache is a dynamic LRU cache (blacklist entries are not in the circular LRU, of course, but the cache was designed that way) for temporarily storing correct DNS answers (with overhead because, yes, each entry has among other things a 64-bit expire timestamp), each entry is created or removed with multiple malloc() and free() calls, so there’s some page size overhead there.

Like I said, there are ways to make a blacklist have a smaller memory footprint, by using a special data structure which trades speed for size, [2] but for a two-day coding project, it made more sense to just add them to the speed optimized LRU cache the code is built around.

[1] As an aside, the hash compression algorithm came out before SIP Hash, but, like SIP Hash, has protection against an attacker finding hash bucket collisions. If I were to write the code today, I would use SIP Hash.

[2] Here is how I would do it: I would have two blocks of data. One block is an array of offsets (pointers, but not C memory pointers) to data in the second block, and the second block is a bunch of NULL-terminated strings compactly stored. The array of offsets is a sorted list, where the sort key is the string each element points to. I would then do a binary search every time I wanted to see if an element is blacklisted. Memory overhead is, for 10 million entries with an average length of 15 bytes per string (including the NULL) 30 million bytes for the offsets and 150 million bytes for the strings, so we could store 10 million entries in under 200 megs. Speed is O(log2(N)) instead of O(1) but we save a lot of memory. We would need more memory to sort that list, but we could store this block as a binary file which is made on a host with a lot of memory, but read on our Raspberry Pi or old Netbook. Again, doing this is left as an exercise for the reader, and I’m sure there’s a lot of public domain or otherwise open licensed libraries which have already solved this problem. If I were to go down that path; I would probably use sqlite, but am a bit reluctant to add sqlite to a tiny program which can compile to be under 70k in size.

Re: Ad blocking with Raspberry Pi and Pi-hole

#34
post #32

Earlier quoted context omitted.

Any chance you can share that shortcut? I currently have a bookmark that my roommate can hit, but a shortcut would be better.

I use a modified version of this with hard coded times so there is no user input: https://routinehub.co/shortcut/2904

thank you for sharing

Re: Ad blocking with Raspberry Pi and Pi-hole

#35
post #10

I wish it were more effective in removing Youtube ads on my kids' iPads, but I understand it's a tall order. At least it gets rid of ads in most other apps.

I pay google the $10/mo. for no ads on youtubeso the kids don't get exposed.

The extra benefits are - play video with the screen off to listen to lectures - youtube music - specifically good for letting the toddler hear the wiggles without having to watch a wiggles video on youtube

I also pay hulu for no ads. I'm happy for the opportunity to pay directly for entertainment instead of with my eyeballs. No way to opt out of tracking, though, hence the pihole.

Re: Ad blocking with Raspberry Pi and Pi-hole

#36

I'm looking for a way to combine the adblocking with a VPN switcher that takes eg NordVPN and routes all my home traffic through a variety of tunnels (they provide a load of openVPN files). Is there a ready-made way to do this? The idea is for anyone in the house to be protected by both the adblock and the VPN.

pfsense can do this pretty easily, i wouldn't call it out of the box though. the adblocking can be done via pfblocker-ng, and it has an openvpn client of course.

Re: Ad blocking with Raspberry Pi and Pi-hole

#37
post #20

Is anyone successfully using PiHole with non-technical users? My main concern with putting PiHole on my home network is that for example my mother in law might not understand that she can't get to some web page because it's being ad-blocked, nor would she be able to go to the web admin page and temporarily unblock it. Even as a technical person sometimes it takes a while to figure out that a page isn't working becaus…

In addition to what other people have said, you'll have a nightmare of a time if the power goes out and your router re-assigns new LAN IPs (nightmare if you're not in the same household as the non-technical user). Try to setup a Pi-Hole with a static IP if you can.

[Edit] Grammar.

Re: Ad blocking with Raspberry Pi and Pi-hole

#39
post #8

I use pi-hole, and it's great, but for browsers you still need something like uBlock Origin installed to properly block ads. The thing I like about pi-hole is it also blocks a long list of trackers that are bundled by various mobile SDKs. There's no way to block those with iOS or Android, except at the network level.

I've been using Pi-Hole for quite a while now too. I also have several in-browser ad blockers. In browser, I'm running Ghostery, uBlock Origin, and Privacy Badger, DuckDuck Go's privacy essentials, and whatever Firefox's does when you turn on all of the privacy respecting stuff. Honestly, I don't really know what does what any more. I recently turned off pi-hole and started to browse the web using Internet Explorer, just to see. Holy Cow... I'd forgotten what the incredible-edible internet was really like.

Re: Ad blocking with Raspberry Pi and Pi-hole

#40
post #25

Please do note that Android appears to be quite weird in regards to accepting network set DNS. My observations so far have been that Android tends to ignore any DNS set by either the network via DHCP or statically set. Android instead probes the gateway for 8.8.8.8, and happily uses that instead. The only way I have been able to solve this has been to setup a VPN (I prefer wireguard) on the pihole. Android seems to a…

If you have a decent router, then you can just forcibly redirect any DNS requests from 8.8.8.8 to your PiHole.
Post reply on HN