I'm trying to configure dnsmasq
to work along with NetworkManager
, the problem is when I try to run the service it fails with:
dnsmasq: failed to create listening socket for port 53: Address already in use
However nothing is listening on 127.0.0.1:53
:
sudo ss -alpn sport = 53 src 127.0.0.1
The above command has no output!
Here is what my /etc/dnsmasq.conf
looks like:
$ grep '^[^#]' /etc/dnsmasq.conf
no-resolv
server=8.8.8.8#53
listen-address=127.0.0.1
cache-size=50
The issue can be fixed if I enable bind-interfaces
in /etc/dnsmasq.conf
.
Why should I enable this? the comments states that:
About the only time you may need this is when running another nameserver on the same machine.
So I thought the issue might come from systemd-resolved.service
and sure it was. after stopping it:
sudo systemctl stop systemd-resolved.service
now dnsmasq
is working fine without bind-interfaces
option being enabled.
I'm running Ubuntu 18.04.1.
Installed using debootstrap
and my default renderer is NetworkManager
which is working fine.
My questions are:
- Why do I have to enable
bind-interfaces
? - Is it okay to just disable
systemd-resolved
service? if it is how should I getdnsmasq
to control/etc/resolv.conf
? - And more important, why I'm getting that weird error message when nothing is listening on port
53
?
By default Dnsmasq tries to bind the port over all interfaces. Where
--bind-interfaces
only interface declared in the configuration.man dnsmasq
Similar cases:
More advance related topic:
Here is my working example. I can remember i had the same issue because my "buster" had systemd-resolved.service enabled. However it's been a while since I used it the last time, but the following config has nothing big special inside:
Hope this helps
Best regards
Sascha