2

I came across the idea of adding many domain names to an hosts list to prevent "malvertising" (malware hidden in ads). How does this compare to using an adblocker?

Using an host files seems better to me at first sight, but are there performance concerns with a very large list? Is there a reason why adblocker might be better?

6
  • Besides needing to update the hosts lists manually while adblocker updates itself?
    – schroeder
    Jan 29, 2020 at 11:15
  • Yes, that is one good point, but I am interested indeed in other differences as well.
    – DevShark
    Jan 29, 2020 at 11:16
  • So, not all the other features but just applying the sqame list using both methods?
    – schroeder
    Jan 29, 2020 at 11:17
  • No, actually I am interested in the other features as well. At first sight, it seems to me that the hosts approach is superior. But that might be because I do not know well enough how adblockers work. There might be features in adblockers that are useful, and superior to what the hosts approach offers.
    – DevShark
    Jan 29, 2020 at 11:26
  • So, have you looked up how the programs work? adblockplus.org/en/about
    – schroeder
    Jan 29, 2020 at 11:29

1 Answer 1

2

It's most a tradeoff between management effort and easy of use.

An adblocker will usually run inside the browser, and have some performance impact. They will use memory and CPU time to parse the incoming HTML data, search his internal database to match ads, and remove them from the page. All that incurs some performance penalty. The biggest benefit is that it is a fire-and-forget approach: you choose the adblocker, install it, and it's done.

On the other hand, a hosts file (or DNS server like PiHole) will work on network level. All requests from the blacklisted domains will return an invalid or unreachable address (configurable), so the client will not spend any resources blocking anything. As it works at network level, every program on your computer, and every computer on your network will be protected.

On the downside, it needs more administration. If you install PiHole, you need to be comfortable with installing Linux services, will probably need a dedicated device, and will need to manage this device to keep it running.

If you keep a hosts file, you will need a script or program to manage it and keep it updated. Performance impact will be way less than running a program inside the browser to parse HTML using regex.

2
  • Great, thanks for that. So a little more administrative effort, but better performance, and same protection.
    – DevShark
    Jan 29, 2020 at 14:40
  • 1
    Performance impact is just on CPU/RAM but not function in operation, though. If I put the AdBlocker lists in /etc/hosts, there is no way to granularly permit connections based on site. StackExchange, for example, becomes non-functional with AdBlocker turned on. If I tried to use hosts I would have to figure out which entries needed to be unblocked, unblock them, browse, then block them again. With AdBlocker, I can turn it off based on the domain I'm browsing and put in filtering rules.
    – schroeder
    Jan 29, 2020 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .