dns-sniper is a command line utility that combines online DNS blacklists and combines them into the desired configuration format.
- HOSTS
- plaintext (hostnames as newline-seperated list)
- bind 8
- dnsmasq
- HOSTS
- plaintext (hostnames as newline-seperated list)
- unbound
Using bundler, add to the Gemfile
:
gem 'dns-sniper'
Or standalone:
$ gem install dns-sniper
require 'dns-sniper'
hostnames = DNSSniper::Hostnames.new
# Manually add blacklisted or whitelisted domains
hostnames.blacklist += 'ads.yahoo.com'
hostnames.whitelist += 'favoritewebsite.com'
# Use an Importer to process external lists
hostnames.blacklist += DNSSniper::DomainsImporter.new('https://github.com/raw/brodyhoskins/dns-blocklists/master/tracking.list').hostnames
hostnames.blacklist += DNSSniper::HostsImporter.new('https://pgl.yoyo.org/as/serverlist.php?hostformat=hosts;showintro=0;mimetype=plaintext').hostnames
# Blocklist is accessible as an Array
hostnames.blocklist
# List available formats
DNSSniper::Exporters.all
# Convert to desired format
hostnames.to_unbound
See dns-sniper --help
Using the CLI version makes it easy to update configuration formats automatically. For example:
#!/usr/bin/env bash
/path/to/dns-sniper --conf ~/.config/dns-sniper/dns-sniper.yml --output unbound > /etc/unbound/unbound.conf.d/blocklist.conf
service unbound reload