645 – mobile ad blocking

It's always DNS

The internet just wouldn’t work without the magic that is the Domain Name System, or DNS. If you are not a networking guru, this service is effectively the index of internet hosts (not just websites but also anything else that offers a service on the net), and is used to find the actual address that your computer will connect to, using a name as the reference.

If you put www.bbc.co.uk into your browser, that means you want to connect to a machine called www which belongs to the domain bbc.co.uk, and a beautiful yet simply elaborate system is used to figure out how to find that domain, get the address(es) of the actual host, and provide the info back to your device so you can connect to it and request information.

Being the one service to bind it all also means DNS is often the thing that brings everything to a halt, eg. if your home router can’t connect to your ISP’s DNS server, then you’re basically unable to communicate with the rest of the world as you’d be unable to find anything (unless you hard-code your machine to use a different DNS, like CloudFlare’s or Google’s

Futzing about with DNS can sometimes bring benefits, though. One such is that for the many webpages which contain embedded adverts or clickbait links, if your browser is unable to connect to the source of the advert, then it might just not show the content at all. On desktop computers, you could use ad blocker browser extensions of all kinds, but on mobile devices your choices are a bit more limited.

Stupid Ad from Microsoft Start appIf you rely on mobile apps like Google News or Microsoft Start, which show content within the app and have no ability to install 3rd party browser extensions, you may have to take more action to block out all the insidious and stupid adverts.

A true geek’s solution at home could be to set up a Pi-hole; a DNS server (traditionally targeted to run on a Raspberry Pi microcomputer, hence the name) which will filter out the garbage by deliberately blocking the URL-to-address resolution of thousands of known advertisers or clickbait providers. Great when you’re on the home network, but what about if on the move and connected to another network?

One possible solution here is to use a provider like NextDNS, which has been described as effectively running a Pi-hole in the cloud for you to use.

Enable NextDNS on AndroidFree for up to 300,000 name resolutions (which sounds like a lot, but in reality, isn’t), it’s a snap to try out and if you sign up, you’ll be given simple instructions on how to plug it into your phone, tablet, desktop or even home router, so as to extend protection to every device connecting through that network.

Insidious ad has been silently blockedDNS queries would be routed to the NextDNS service and if the requested host is from one of a plethora of blocked sites – not just ads, but known trackers, phishing links etc too – then it will simply return a dud response as if the site doesn’t exist.

Your app or browser will either show you an empty box, maybe an inline error frame, or it may silently move on and display nothing at all. Just one small victory!

Using a service like this – others are available – can be switched on or off quickly (in Android, it takes the form of a single switch to configure a Private DNS with a URL unique to your account), and works regardless of whether you’re on Wi-Fi or mobile connectivity.

Tip o’ the Week #292 – Stop the ads on Edge

clip_image001Advert blocking in Internet Explorer was covered back in ToW #247, highlighting some ways to stop annoying adverts from taking over your browser. The internet has plenty of examples of misplaced advertisement, not all of them online banner ads.

There’s a burgeoning industry in providing ad-blocker type extensions for browsers, which basically intervene and elect not to show you the ads – or the “suggested content” or other stuff that not only clutters up your favourite web pages, but also slows down their loading.

Most ad-blocking software runs inside the browser to analyse what’s going on and decide if it wants to let content through. Thing is, the Microsoft Edge browser in Windows 10 doesn’t (yet) have extensions, so there’s not much to do about adverts if you’d like to use Edge as your browser.

3rd party software

Some 3rd parties have started offering software that purports to stop ads in Edge – eg. Adguard Adblock, but whether not looking at ads is worth the $20 fee for use (beyond a trial period) is debatable. Either wait for more support from ad-blocking specialists, for updates from Microsoft which may help, or look to other solutions.

HOSTS file manipulation

Deep in the roots of the TCP/IP protocol which underpins the internet, lies an anachronism known as a HOSTS file. This was provided originally to tell your machine how to find other machines’ IP addresses given their names; they sometimes took precedence over other methods (like Domain Name System, DNS) or were a useful backstop if a name/address couldn’t be found trhough other means. Ultimately, HOSTS became unnecessary for the most part.

To see if your PC has a HOSTS file already, try running (WindowsKey+R):

notepad %systemroot%\system32\drivers\etc\hosts.

There is a neat trick to immediately block a lot of well-known advert-serving sites. Think of it that the web page you’re reading is also telling your browser to go to sitea.com, siteb.net and sitec.biz to show you lots of ads and other content from those places. If you were to put a hosts file on your PC, which specified that each of these sites refers to the mysterious concept called “localhost”, then it means your PC will quickly redirect to itself when it comes to serving up any of that content, and it will immediately fail and move on.

Several online communities maintain communal hosts files that list the URLs of a lot of common advert sources, and if you drop an appropriate file on your PC every few months (or whenever you notice there are more annoying adverts appearing), it will quietly deal with the menace, and operates at a low level so you don’t need to do anything to your browser(s).

Find a HOSTS file

There are many out there, but a good one is from MVPS.org (which lists ~15,500 known ad-serving URLs):

  • Click http://winhelp2002.mvps.org/hosts.zip to download to your PC
  • In Microsoft Edge, click the View downloads button
  • You should see the hosts.zip file at the top of your list on the right – click on it to open
  • Double-click on the mvps batch file, then select Extract all then Extract, to unzip the whole lot into a folder
  • Select with left-click, then right-click on mvps and choose Run as administrator to update your hosts file
  • You can always go back into your downloads folder and delete the folder created above – its work is done

You will likely need to tweak the registry to enable Hosts resolution:

  • Press WindowsKey+R then run regedit
  • Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters then
  • Click Edit > New > DWORD Value then type MaxCacheTtl
  • Click Edit > New > DWORD Value then type MaxNegativeCacheTtl
  • Double-click on the MaxCacheTtl key on the right pane, and enter the value 1
  • Double-click on the MaxNegativeCacheTtl key on the right pane, and enter the value 0

Another option would be to open this zip file, then double-click the file within, click Run, then Yes, Yes and OK. Assuming you trust this site, you won’t now be showing up on some list of transgressors, you’ll just have avoided the grubbiness of editing the registry as per the section above.

Now let’s compare one page:






clip_image006Some sites will substitute blank space for the missing ads, but for content like the Other Stuff you might want to click on (such as the Taboola-type clickbait guff that’s normally at the bottom of the page), site may just quietly ditch whole sections without you ever knowing.

You may see the odd weird missing bit on some pages (eg from Ebay, see >>>), but that’s surely a fair price to pay for not cluttering up your machine with annoying adverts, having auto-playing videos blaring at you, etc. Now if they only made adverts like they used to, it wouldn’t be such a chore.

Pea & Ham, from a Chicken? Now that’s clever.