/etc/resolv.conf contains go-dnsmasq ip on first line cause long resolve times
Closed this issue · 2 comments
Hi, I found strange behaviour of go-dnsmasq. I run it in docker on one of my servers. Assume that this server ip is 192.168.140.25.
When my /etc/resolv.conf (on host, not in docker) contains only :
nameserver 8.8.8.8
nameserver 8.8.4.4
and I start go-dnsmasq and after start I change /etc/resolv.conf to:
nameserver 192.168.140.25
nameserver 8.8.8.8
nameserver 8.8.4.4
everything works as expected. Resolve times(measured by dig) are around 20ms for addresses not listed in hosts file and 0ms for addresses listed in hosts file. Great!!
But when my resolv.conf looks like this
nameserver 192.168.140.25
nameserver 8.8.8.8
nameserver 8.8.4.4
and I start go-dnsmasq in docker dig times rise to 3000ms for domains not listed in hosts file and 0ms for domains listed in hosts file. I can understand this behaviour go-dnsmasq reads /etc/resolv.conf and start to question itself (first line). But I need the first line in resolv.conf to resolve local adresses to 192.168.140.* on this server and couple of others in 192.168.140.* range.
So I found $DNSMASQ_SERVERS enviroment var. I set it to "8.8.8.8, 8.8.4.4" and I thought this way go-dnsmasq won't look in /etc/resolv.conf and use 8.8.8.8, 8.8.4.4 as DNS, but I think it still does look in /etc/resolv.conf because resolve times (measured by dig) are still around 3000ms when my /etc/resolv.conf looks like this (before I start go-dnsmsasq) :
nameserver 192.168.140.25
nameserver 8.8.8.8
nameserver 8.8.4.4
As a workaround I change /etc/resolv.conf(add 192.168.140.25 line) after I run go-dnsmasq, but It's not practical. And when I have docker "restart: always" feature turned on and I restart my server, go-dnsmasq container autostarts and problem comes back, because in moment of start go-dnsmasq /etc/resolv.conf contains line: nameserver 192.168.140.25 at the beggining.
I think when $DNSMASQ_SERVERS env_var is set go-dnsmasq should not look in /etc/resolv.conf and use DNS listed in env variable.
Maybe I should correct something in my setup or it's something related to docker but it drives me nuts ;]
Anyway......great soft. Big thanks.
Sorry for bothering. It was mistake in my setup - too much work last days. This issue should be deleted/closed.
It's was my stupid mistake. I use "NAMESERVERS" as a env_var name and it should be "DNSMASQ_SERVERS". When I change env_var name to "DNSMASQ_SERVERS" and set it to "8.8.8.8,8.8.4.4" everything works as expected no matter /etc/resolv.conf contains at the moment of go-dnsmasq start. No strange resolve times. Great.
Thanks again for great software
Cheers
sysadmin from Poland
@wroobel79 Glad you worked this out by yourself! 😄 Pozdrowienia z niemczech.