Sign inSign up

creativeprojects/hosts-filter

By creativeprojects

Updated 3 days ago

Compile various domain blocklists and save into your hosts file. Unix, macOS and Windows.

Image
Networking
Operating systems
0

3.7K

creativeprojects/hosts-filter repository overview

Introduction

Compile and update your hosts file from various block lists. Works on various unixes, Linux, macOS X and Windows.

This tool simply download lists of bad domains (adware, spyware, phishing, scam, etc.) and adds an entry into your hosts file like:

0.0.0.0 bad.domain

which means your computer cannot find the malicious domain to load as it points to an invalid IP (0.0.0.0).

Configuration

Put all the block list URL into a config file config.yaml:

---
# hosts file to update (leave blank for the system default)
# hosts_file: /etc/hosts

# IP used for filtered domains: default is 0.0.0.0
# ip: 0.0.0.0

block_lists:
  -
    url: http://winhelp2002.mvps.org/hosts.txt
  -
    url: http://someonewhocares.org/hosts/hosts
  -
    url: http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext

# list of domains to remove from the lists
# allow:
#   - github.com

# file containing a list of domains allowed (one per line)
# allow_from: allow.txt

Usage

hosts-filter [flags]

hosts-filter flags:
  -c, --config string   configuration file (default "config.yaml")
  -h, --help            display this help
  -l, --log string      logs into a file instead of the console
      --no-ansi         disable ansi control characters (disable console colouring)
  -q, --quiet           display only warnings and errors
  -r, --remove          clear up the hosts file of all entries generated by hosts-filter
  -o, --stdout          don't save the hosts file in place, but send it to the standard output instead
  -v, --verbose         display some debugging information

Compile block lists and update your hosts file

$ sudo hosts-filter

loaded "http://winhelp2002.mvps.org/hosts.txt": 8815 entries in total
loaded "http://someonewhocares.org/hosts/hosts": 22069 entries in total
loaded "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext": 24890 entries in total

Remove the block lists from your hosts file

$ sudo hosts-filter -r

Using docker image

By default, the hosts-filter container starts at /hosts-filter. So you can feed a configuration this way:

$ docker run -it --rm -v $PWD/examples:/hosts-filter creativeprojects/hosts-filter

License

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. https://creativecommons.org/licenses/by-nc-sa/4.0/

Tag summary

Content type

Image

Digest

sha256:0b45c9a34

Size

6.3 MB

Last updated

3 days ago

docker pull creativeprojects/hosts-filter