I'm running Debian Jessie and I'm trying to configure dnsmasq as a caching DNS server. I used a guide to come up with the following /etc/dnsmasq.conf
:
listen-address=127.0.0.1
bind-interfaces
domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
neg-ttl=3600
resolv-file=/etc/resolv.dnsmasq
no-poll
Doing sudo service dnsmasq restart
fails and it won't start, telling me
Mar 26 17:13:01 user dnsmasq[26743]: dnsmasq: syntax check OK.
Mar 26 17:13:01 user dnsmasq[26746]: dnsmasq: only one resolv.conf file allowed in no-poll mode.
Ok, kind of strange that a config straight out of a guide failed. I'll just remove the no-poll
option to see if it works. This time it starts just fine, but DNS resolution is clearly failing. Relevant files:
/etc/resolv.conf
:
nameserver 127.0.0.1
/etc/resolv.dnsmasq
:
nameserver 8.8.8.8
/var/run/dnsmasq/resolv.conf
:
nameserver 127.0.0.1
The third file appears to be dnsmasq's live resolv.conf file, because adding a nameserver line to it while dnsmasq is already running causes DNS resolution to immediate start working. So it looks like it ignored my /etc/resolv.dnsmasq
. I also tried adding a nameserver line to my /etc/resolv.conf
and removing the resolv-file
line in /etc/dnsmasq.conf
, but it gets overwritted immediately to what you see above upon doing sudo service dnsmasq restart
.
What is going on with dnsmasq and do I configure dnsmasq as a caching DNS server?
server=8.8.8.8
in your dnsmasq config?no-poll
basically says to ignore theresolv-file
. At startup, it takes whichever file is newer, so that will be/etc/resolv.conf
in your case (because it gets rewritten when something changes).