gaenserich / hostsblock

an ad- and malware-blocking script for Linux
https://github.com/gaenserich/hostsblock
225 stars 28 forks source link

Leverage DNSMasq #37

Closed hemsleyk closed 9 years ago

hemsleyk commented 9 years ago

Just FYI, dnsmasq will read hosts files and generate zones from them.

So you could use that for ALL of the heavy-listing. It even has a config option / flag (-b) to instantly report failed resolution for host-local addresses (127.anything, 0.0.0.0) and can cache somewhere around a thousand names in RAM (uses ~8MB RAM after running 5 days heavy browsing). That would make it a hard dependency though, so ...

Source: http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

Can even specify a directory containing multiple hosts-formatted files ;)

gaenserich commented 9 years ago

Is this any different from the "second" default configuration, where instead of /etc/hosts, hostsblocks compiles its final list to /etc/hosts.block? From there, I add the line addn-hosts=/etc/hosts.block to /etc/dnsmasq.conf.

hemsleyk commented 9 years ago

You're ... actually right. Proves the worth of actually reading the docs.

I sort of wonder though if there's a way to have dnsmasq return NXDOMAIN for hosts-formatted entries ... but that's an inquiry to make with their community.