Svenv.nl

Home Hands holding megaphones

Getting rid of ads on OSX and iOS (the hard way)

Ad blockers are becoming more and more common on desktops and laptops and ever since Apple allowed ad blockers in iOS 9 (at least in Safari) it’s easier than ever to block these annoying ads on all your devices. Still, ad blocking plugins might not be the best way of keeping your browser ad-free.

Why should we block ads?

Apart from providing a more pleasant browsing experience, blocking ads has various other advantages:

Personally, I don’t think the faster page loads are that important. However, I don’t like being tracked around the web by ads that act as a nice platform for exploits.

Why shouldn’t we block ads?

The debate about ad blockers focusses primarily about the question whether ad blocking is theft. Basically, an ad blocker takes away an opportunity for content creators to earn an honest living.

I cannot deny that to some extend this is true (although I wouldn’t call it theft). However, I also think that my privacy and the safety of my computers is more important than the ability for an ad to appear on my screen. But they don’t have to rule each other out.

The alternative

The problem is that I don’t trust advertisement networks and the way they collect data. This doesn’t mean I don’t trust the authors and creators of the websites I tend to visit. What if I could just block ad networks and still allow websites to serve their own ads using there own domain? Well, it’s possible…

Ad networks operate from various domains, these domains are typically only intended for serving ads. Blocking these domains wouldn’t harm your internet connection and will prevent a lot of ads from loading in the first place.

Blocking these domains can be done by Installing a custom hosts file (instructions available). This wil help you get rid of almost every ad network out there right away but will technically still allow content creators to serve ads from their own domain.

If you installed a custom hosts file and still see ads from ad networks, you might need to clear your DNS cache for it to work. In my case (OS X El Capitan), I also had to disable ipv6 support for the doubleclick network as it provided an ipv6 fallback (I didn’t block the ipv6 address in the hosts file as the host file gets updated automatically on my machine).

What about iOS?

You can’t change the hosts file in iOS (without a jailbreak at least) and therefore a DNS server will have to change the ad networks for you. You can't just choose your DNS server on cellular networks so blocking ad networks is close to impossible, or is it?

OpenVPN to the rescue

iOS supports the use of a VPN network, these private networks provide some additional functionality for your network/internet connection. If your willing to set up a VPN, you can block ad networks.

These are the steps you need to take:

If you follow these steps, You’re able build your own “ad blocking network”.

I use OpenVPN in conjunction with dnsqmasq to provide such a service. The result is that almost every ad network is blocked while theoretically content creators are still able to serve ads that don't invade my privacy. In practice almost every ad serving website uses ad networks, but at least they now have a chance to serve ads again.

Published on March 15, 2016, 11:30 p.m.