HostBlocker is an application that builds lists to block known problematic domains (e.g., associated to Spam, malware, tracking). It takes a configuration file with multiple lists of such domains, and builds a unified output file, with a configurable format (currently it supports /etc/hosts, Dnsmasq, Bind/RPZ and Unbound formats). When using Bind output format, it can group multiple sub-domains under a common wildcard domain, in case both the base domain and certain number of different sub-domains are present. For Unbound, sub-domain of blocked domains are discarded, as blocking a domain automatically blocks a sub-domain. With Unbound format, SOA records are also generated (which allows to define the TTL for NXDOMAIN responses). Moreover, it allows to specify a blacklists, a whitelist, and a custom header.

Each source list may have a different format. Mapper and filter functions should be used to obtain the valid/desired domains from each list. That is, for each line of a list, first a sequence of mapper functions is applied to obtain the domain from the line, and then a sequence of filter functions is applied to determine if the domain should be used or discarded.

Moreover, each list has associated a score, and only domains for which the sum of scores from the different lists is above a certain threshold are used. This allows users to use less reliable lists, without risking blocking wrong domains (assigning a low score to the list, we make sure the domain is blocked only if it appears in other lists too).

This application caches the downloaded files for a configurable amount of time (60 hours by default), to avoid downloading the file to often. The cache directory can be specified with the environment variable HOSTBLOCKER_CACHE_PATH (uses relative directory cache by default).




HostBlocker (1.4)


  • 1.4 (2018-01-05)
    • Add support for Unbound.
  • 1.3.1 (2018-01-05)
    • Code refactoring.
    • Change default score threshold to 0;
    • Allow specification of IP for hosts file;
    • Sort output by reverse domain;
    • Set remote connections timeout to 10s.
  • 1.3 (2018-01-03)
    • Add support for Bind.
  • 1.2 (2017-12-23)
    • Code refactoring;
    • Add support for Dnsmasq.
  • 1.1 (2017-12-11)
    • Improve AdBlock mapper;
    • Add support for caching sources.
  • 1.0 (2017-12-10)
    • Initial version,