# the first command is a one time only job
cp -vip /etc/hosts /etc/hosts.default
# the following is the automation.
curl http://someonewhocares.org/hosts/hosts --silent > /etc/hosts.sowc
cat /etc/hosts.default /etc/hosts.sowc >> /etc/hosts
The other benefit of this is you can then just do a `dnsmasq reload` (since the hosts file is an external configuration file) rather than the full `dnsmasq restart` that dnsgate performs.Thanks for the recommendation.
echo "conf-file=/etc/dnsgate/generated_blacklist.conf" >> /etc/dnsmasq.conf
RE intermixing hosts file: dnsmasq supports reading from additional hosts files other than /etc/hosts (thank to creshal for that suggestion: https://news.ycombinator.com/item?id=10580082)
Thinking a little more about the problem you raised, I guess you could grep it for IPs that aren't localhost (ie exit the shell script before writing the new hosts if `grep` returns a zero exit code). Aside that, I'd genuinely be interested in any ideas you have for keeping the file updated in a secure way (if at all possible).
You should still have a modicum of trust towards the host you're pulling from, as they can also insert something to potentially break the parsing code, which opens up a whole 'nother host of issues.
Moving /etc/hosts to /etc/hosts.default is much better than the 'hosts example'. Updated it. Thanks. Still experimenting with 'dnsmasq reload' but if it works as advertised that's more general than restarting the service.
from man dnsmasq:
-B, --bogus-nxdomain=<ipaddr>
Transform replies which contain the IP address given into "No such domain" replies.
This is intended to counteract a devious move made by Verisign in September 2003
when they started returning the address of an advertising web page in response to
queries for unregistered names, instead of the correct NXDOMAIN response. This
option tells dnsmasq to fake the correct response when it sees this behaviour. As
at Sept 2003 the IP address being returned by Verisign is 64.94.110.11
Is there another way to get dnsmasq to return NXDOMAIN? If I am reading this correctly, one would need to do 'dnsgate --dest-ip 127.2.2.2' and then tell dnsmasq '--bogus-nxdomain=127.2.2.2'. servers-file=/usr/local/etc/dnsmasq-servers.conf
and then that file contains a lot of lines like: server=/taboola.com/
The docs don’t tell you that this results in NXDOMAIN for the server whose IP you didn’t specify. It seems to work!