This page looks best with JavaScript enabled

Changing the hosts file to avoid commercials

 ·  ☕ 5 min read  ·  🤖 SWU

At some point, unfortunately I don’t know where or how, I came across Blocking Unwanted Connections with a Hosts File. At that point I had been sensitive to advertising for a long time and had installed an ad blocker in my web browser, and that was really, a long, long time ago. I guess at that time I had been using Windows 7 and still no Linux computer or something. The key point is that website operators don’t even advertise themselves, but rather book service providers who do it. These are web servers from other domains. If you prevent the loading of the websites of classic operators of such services, you get websites without advertising.

Since then I have been using a miles and miles hosts file and no longer needed an ad blocker.

In Windows, Linux and Android.

The hosts file originally comes from Unix, in Windoses it is in
and in *nixes in

Google yourself for “block hosts file advertising”

The technology that is why this works is that when the operating system asks which IP address is behind a name in the network, it first asks the local hosts file so that it can save itself a complex DNS query and work faster and more efficiently. Where an ad blocker in the web browser consumes additional time and energy to filter out advertisements, such effort is simply superfluous with an adapted hosts file.

If you now fill the hosts file with crude entries for web servers that you don’t even want to load, it looks like this

and regular entries like that localhost cucumber.lan cucumber

Calling up a website in my web browser may also call up, but this leads to a failure because the IP address cannot be loaded. So the website loads for me without reloading

The above mentioned website offers a zip file, the content of which is a hosts file with many web server entries that offer tracking cookies or advertising and a batch file to copy the hosts file into the system that needs administrator rights. Since then there have been many such websites that offer this service one way or another for all operating systems.

For Android e. g. Adaway is such a software that offers to copy the hosts file into the system for a rooted smartphone. For non-rooted smartphones, you can select a VPN in the Adaway app that serves the same purpose by filtering network traffic using a local hosts file.

Since I have such an app in Android and such a hosts file in my operating systems, I no longer need ad blockers because the advertising is not even loaded.

The reaction of websites to my browser situation is mixed. There are many websites out there that take no notice of it. Some give an OK for the findings and ask for a handout, others strictly reject the request and demand that the ad blocker be turned off.

Discussions about ad blockers are also mixed. There is both understanding and rejection.

Personally, I think I am the wrong target for web advertising because, in my opinion, my buying behavior is not triggered by advertising, but by decisions I have made myself. In addition, advertising is almost always attention-grabbing and disturbs me significantly when reading a website. Even if I’ve made up my mind For example, to make a substantial purchase, this is followed by research so that I can weigh what and where to buy. This includes offline research and under no circumstances do I use advertising on websites for this. I am not a candidate for it.

I am aware that websites do not earn any money from visiting them. This is a problem for which I have no solution. My defense is that there is no standard for advertising that will protect me from distracting my attention, in other words, causing me stress to see ads. I am more close to myself than to them and need to protect myself. So I don’t visit websites that insist on loading commercials.

After many years of silence, there have recently been attempts to break this situation by discussing DNS over HTTPS and arguing that this would increase privacy and security. The setting in the web browser to use DNS over HTTPS excludes the use of the hosts file.

For me and other users of a customized hosts file, privacy and security do not increase, in my opinion not for everyone else either. There were / are definitely man-in-the-middle attacks that manipulate DNS queries, but this is not a standard attack because it would be so efficient and would therefore be used with pleasure. Other methods such as phishing appear to be more successful. Incidentally, one can also ask oneself whether such an attack would actually be warded off by using DNS over HTTPS. Attackers aiming to manipulate DNS can safely take this into account if the victim uses and circumvents DNS over HTTP.

DNS over HTTPS therefore has no noticeable gain, but on the contrary weakens the position of the computer user because the hosts file is no longer used and should not, in my opinion, be recommended in the first place.

I also have a tip against advertising in YouTube videos. Just install the Brave Browser, it comes with a plugin that takes care of that.