Hostsblock is a bash script designed to take advantage of /etc/hosts file to provide system-wide blocking of internet advertisements, malicious domains, trackers, and other undesirable content.
To do so, it downloads a configurable set of blocklists and processes their entries into a single /etc/hosts file.
Hostsblock also acts as a command-line utility that allows you to block and unblock certain websites and any other domains contained in that website.
– NEW: Enhanced security – Runs as an unpriviledged user instead of root.
– System-wide blocking – All non-proxied connections use the HOSTS file (Proxied connections can be modified to use the HOSTS file)
– Compression-friendly – Can download and process zip- and 7zip-compressed files automatically. (Provided that unzip and p7zip are installed)
– Non-interactive – Can be run as a periodic cronjob or systemd timer without needing user interaction.
– Extensive configurability – Allows for custom black & white listing, redirection, post-processing scripting, etc.
– Bandwith-efficient – Only downloads blocklists that have been changed, using http compression when available.
– Resource-efficient – Only processes blocklists when changes are registered, uses minimal pipes.
– High performance blocking – Only when using dns caching and pseudo-server daemons.
– Redirection capability – Enchances security by combating DNS cache poisoning.
– Extensive choice of blocklists included – Allowing the user to choose how much or how little is blocked/redirected.
hostsblock Version 0.999.6 (Alpha 6) (03.08.2017):
+ Fixed parsing function that falsely expected gzip
+ Fixed verbosity typo
+ Fixed issue with hostsblock-urlblock symlink not reading from $1
+ Moved raw annotation file to cache space to improve performance and reduce non-transitory space requirements
– curl http://curl.haxx.se/
– GNU bash http://www.gnu.org/software/bash/bash.html
– GNU sed http://www.gnu.org/software/sed
– GNU grep http://www.gnu.org/software/grep/grep.html
– GNU coreutils http://www.gnu.org/software/coreutils
– GNU gzip (or pigz for multi-core systems) https://www.gnu.org/software/gzip/
git clone https://github.com/gaenserich/hostsblock && cd hostsblock
sudo useradd -d /var/lib/hostsblock -c "hostsblock" -m -U hostsblock
Don't forget to enable and start the systemd timer with:
systemctl enable --now hostsblock.timer
sudo -u hostsblock ./hostsblock.sh -c https://www.facebook.com