Adsuck – a small DNS server that spoofs blacklisted addresses
opensource.conformal.com
opensource.conformal.com
# 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.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.
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)
echo "conf-file=/etc/dnsgate/generated_blacklist.conf" >> /etc/dnsmasq.conf
Thanks for the recommendation.
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!dnsmasq can read from the hosts file and the whole thing is automatically updated once a week with the latest bad domains (a simple `curl` request is all that's needed)
This method also ports much easier to other *nixes and even Windows since dnsmasq already has wider platform support.
[1] http://someonewhocares.org/hosts/
If I might mention my own site for a minute, I maintain a list of ad server (and tracking server) hostnames: http://pgl.yoyo.org/adservers/
You can view the list as a dnsmasq config file, a BIND config file, and a bunch of other formats.
Although I don't have such devices in my network, I've heard that others do this to their "smart" TV/media box/creepy home surveillance gadgets.
What's your router model?
But that aside I wasn't suggesting that people run dnsmasq on their primary workstation. It's certainly an option, but I personally think it's better to have dnsmasq on a spare machine which is always on (doesn't need to be beefy, a Raspberry Pi would easily be more than capable). That way you can plum your dnsmasq IP into your DHCP server (or even use dnsmasq as your DHCP server as well) so that your phones, tablets and other devices all also benefit from ad blocking / tracking / etc.
Another option with dnsmasq is to run it directly on the router. Some consumer routers, such as Asus, allow you to access the device's command line via telnet / SSH. In the case of Asus, they literally just run dnsmasq for their DNS and DHCP daemons, so you could apply the hosts file directly on the router if you wished.
dnsmasq has the --addn-hosts parameter for that, so you can keep the list in a separate file.
I'd say a script for any of these would be a better choice.
BIND has had RPZ support for years and other resolvers are working on the feature.
I know i could add it to other existing servers, but i'd really love a really small independent virtual machine which sole purpose would be DNS.