Este script de shell compatible con POSIX, diseñado para sistemas tipo Unix, obtiene una lista de dominios que sirven anuncios, rastreo de scripts y malware de múltiples fuentes confiables y crea un archivo hosts que evita que su sistema se conecte a ellos. Este script selecciona solo los nombres de dominio para cada fuente, de modo que si un nombre de dominio es redirigido a un servidor deshonesto,su sistema no se verÔ afectado. En el peor de los casos, puede perder el acceso a un nombre de dominio legítimo debido a un falso positivo, pero puede revertirlo agregando ese dominio a la lista blanca.
Instalacion:
curl -o /tmp/hblock 'https://raw.githubusercontent.com/zant95/hblock/v1.4.1/hblock' \
&& echo '3da144b2f6cca9ab8e38ed06d05ca96f14ebe554b88eb2918841dfac7ba04a12 /tmp/hblock' | shasum -c \
&& sudo mv /tmp/hblock /usr/local/bin/hblock \
&& sudo chown root:root /usr/local/bin/hblock \
&& sudo chmod 755 /usr/local/bin/hblock

TambiƩn puede cambiar el comportamiento predeterminado utilizando estas opciones:
Usage: hblock [options...]
 -O, --output FILE            Hosts file location (default: /etc/hosts)
 -R, --redirection IP         Destination IP for all entries in the blocklist
                              (default: 0.0.0.0)
 -H, --header HEADER          Content to be included at the beginning of the
                              hosts file. You can use the output of any other
                              command (e.g. "$(cat header.txt)")
 -S, --sources URLS           Sources to be used to generate the blocklist
                              (whitespace separated URLs)
 -W, --whitelist ENTRIES      Entries to be removed from the blocklist
                              (whitespace separated POSIX BREs)
 -B, --blacklist ENTRIES      Entries to be added to the blocklist
                              (whitespace separated domain names)
 -b, --backup [DIRECTORY]     Make a time-stamped backup in DIRECTORY
                              (default: output file directory)
 -l, --lenient                Match any IP address from sources, although it
                              will be replaced by the destination IP
                              (default: 0.0.0.0, 127.0.0.1 or none)
 -i, --ignore-download-error  Do not abort if a download error occurs
 -c, --color auto|true|false  Colorize the output (default: auto)
 -q, --quiet                  Suppress non-error messages
 -v, --version                Show version number and quit 
 -h, --help Show this help and quit


Demo

Fuente:https://github.com/zant95/hBlock