Are you feeling overwhelmed with ads when you browse the web? I certainly do! Do you feel that your privacy is being invaded by online trackers every time you visit a website? I often do! Clearly online advertisements and such are becoming more and more annoying and invasive these days. And since a large part of what I do as an IT professional involves the writing and editing business, I’m frequently online researching various topics or reading news or browsing documentation or wading through discussion boards seeking answers to my questions. Not that I’m against advertisements or online tracking in principle — top quality sites like our TechGenix website rely upon advertisements to pay the bills and viewer statistics to attract advertisers, and without the revenue from such sources, we wouldn’t be able to pay our writers! Still, it seems that many sites, especially those focused on news and entertainment, are becoming so aggressive in their advertising that viewing their content is becoming an exercise in futility, and that is really what is behind the recent surge in ad blocking.
What can the frustrated user do about this? One approach is to install an ad blocking program or browser add-ons like AdBlock, AdBlockPlus, uBlock, or uBlock Origin on your device. I’ve used several of these ad blockers in my own business over the years with various degrees of satisfaction. But I’ve also found a simpler and more satisfying approach to blocking ads and trackers that appeals to my inner nature as a tech nerd. This alternative approach has to do with modifying the HOSTS file on my computer. But before I explain what the HOSTS file is if you’re not already familiar with it, let’s go back to basics and trek way out into the outback to consider a more basic networking concept, the loopback address.
The loopback address
As you may recall, Internet Protocol version 4 (IPv4) has several special addresses that are reserved for certain purposes and may not be used otherwise. Two examples of these special addresses include 0.0.0.0 (the unspecified IPv4 address) and 127.0.0.1 (the loopback address). The purpose of the loopback address is that by assigning it to a network interface you thus enable the TCP/IP node (a computer or other networked device) to send IPv4 packets to itself. In other words, if I was a PC and wanted to talk out loud to myself instead of to other PCs around me, I use the loopback address for this purpose. So if you open a command prompt on your Windows device and type ping 127.0.0.1 to see if the loopback address is present, you’ll always get an answer in the affirmative. Well, four answers actually: “I’m here! I’m here! I’m here! I’m here!”
If you’re a PC, there’s also another way you can check to see whether you’re here or not, and that’s by typing ping localhost at a command prompt. This method works because by default Windows defines “localhost” as the hostname representing the IPv4 address 220.127.116.11. Remember that a hostname is a kind of nickname or alias used to identify a node or its interfaces. Computers on a TCP/IP network can communicate with each other either by using their actual name (their IPv4 address) or their nickname (their hostname). And to translate these aliases into real names you need some sort of dictionary, which on a TCP/IP network is called the Domain Name System. DNS, of course, is not just a simple dictionary but a set of different lookup processes distributed in a hierarchical fashion. But the first step involved in looking up the real name for a given alias is, in fact, a kind of dictionary called the HOSTS file.
The HOSTS file
The HOSTS file is a simple text file found on every device that can participate on a TCP/IP network. On Windows computers, this text file is named HOSTS and it can be found in the C:\Windows\System32\drivers\etc\ directory. The file can contain a series of mappings between IPv4 addresses of other nodes on their network and the hostnames of these nodes. Those of us who have been around long enough in the IT profession (“Guilty!”) may still remember configuring IPv4 addresses of the nodes on their TCP/IP networks manually instead of using Dynamic Host Configuration Protocol (DHCP), which is used routinely nowadays. And once you manually assigned IPv4 addresses to all your networked computers, the next thing you had to do was modify the HOSTS file to define hostnames for all your IPv4 addresses — and you had to modify that HOSTS file on every single computer on your network! Fortunately, DNS together with DHCP makes all this unnecessary nowadays, though sometimes I miss the old manual approach that let you get intimately acquainted with the identity of each and every device on your network. Tech is all so impersonal nowadays…
Using a custom HOSTS file for ad blocking
So what does all this have to do with ad blocking? The solution I’ve found for all the PCs in our own business to reduce the number and volume of the most annoying ads and ad trackers is to use a custom HOSTS file that maps the hostnames of the sites generating these ads and trackers directly to localhost or 127.0.0.1. There are several such custom HOSTS file available out there, and the one we use currently is the MVP Hosts File curated and maintained by a former Microsoft Most Valuable Professional (MVP). And I’m not the only one who uses this file. For example, Greg, a reader of our popular weekly newsletter WServerNews who works in datacenter operations for a business in Kingston, Ontario, Canada, told me “I use the HOSTS file you mentioned, it gets updated about once a quarter. I love it, and recommend it to people all the time.” Several other newsletter readers have also reported to me that they use this HOSTS file instead of free or commercial ad blocking programs. The MVP Hosts File is updated regularly with the last update being just last month, and you can also enter your email address on this page to receive email notifications whenever the MVP HOSTS File has been updated.
The only caveat with using this custom HOSTS file is that when it’s updated, you need to copy the new file to the :\Windows\System32\drivers\etc\ directory on each Windows computer on your network. So there may still a bit of manual effort involved in maintaining this approach to ad blocking. But hey, manual hostname resolution is what the HOSTS file was originally intended for, isn’t it? Also as this post on The Electric Wand blog indicates you may need to make a small registry tweak as well.
Finally, another one of our newsletter readers by name of Jurriaan, who works as a photographer and is chief editor of PhotonMagazine.eu, an online digital magazine for the Benelux countries (Belgium, Luxemburg, and the Netherlands), pointed me to a freeware utility called HostsMan that lets you manage your hosts file with ease and can make it easier to do ad blocking. HostsMan lets you update your hosts file using the built-in updater so you can easily install the latest version of a hosts file, and also it allows you to add your own local or remote sources to the hosts file updater. Jurriaan comments about this utility as follows: “We’ve been using it for some years without complaints. HostsMan is using several lists of files which can better be blocked. The program simply downloads public lists. It is possible to get the downloads on an automatic basis, better is to download them by the manual command. There are always a few sites blocked that the user needs. (If such is happening unexpected, it can be annoying.) After downloading, the updates are fully automatically installed. After the installation, the program removes the duplicates.”
So HostsMan is definitely something you may want to try using if you decide to use the custom HOSTS file approach to blocking those annoying advertisements and trackers. Remember, though, that ads do have a place in our capitalist materialist society and it’s not only writers who gotta eat!
Featured image: Flickr / Joe the Goat Farmer