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

sudo ss -alpn sport = 53 src

The above command has no output!

Here is what my /etc/dnsmasq.conf looks like:

$ grep '^[^#]' /etc/dnsmasq.conf 


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:

  1. Why do I have to enable bind-interfaces?
  2. Is it okay to just disable systemd-resolved service? if it is how should I get dnsmasq to control /etc/resolv.conf?
  3. And more important, why I'm getting that weird error message when nothing is listening on port 53?
  • At least on my box, systemd-resolved listens on rather than so try sudo ss -alpn sport = 53 src - or go oldschool and use something like sudo netstat -nlpt | grep :53 Aug 5, 2018 at 22:06
  • Or sudo lsof -i tcp:53
    – waltinator
    Aug 5, 2018 at 22:33
  • 1
    I knew that systemd-resolved is listening on The thing I wasn't aware of was when something is listening on lo it has effects on all IP addresses of lo. After playing around with netcat I figure it out... poor networking knowledge.
    – Ravexina
    Aug 6, 2018 at 6:07

2 Answers 2


By default Dnsmasq tries to bind the port over all interfaces. Where --bind-interfaces only interface declared in the configuration.

man dnsmasq

-z, --bind-interfaces
    On systems which support it, dnsmasq binds the wildcard address,
    even when it is listening on only some interfaces. It then
    discards requests that it shouldn't reply to. This has the
    advantage of working even when interfaces come and go and change
    address. This option forces dnsmasq to really bind only the
    interfaces it is listening on. About the only time when this is
    useful is when running another nameserver (or another instance
    of dnsmasq) on the same machine. Setting this option also
    enables multiple instances of dnsmasq which provide DHCP service
    to run in the same machine.

    Enable a network mode which is a hybrid between
    --bind-interfaces and the default. Dnsmasq binds the address of
    individual interfaces, allowing multiple dnsmasq instances, but
    if new interfaces or addresses appear, it automatically listens
    on those (subject to any access-control configuration). This
    makes dynamically created interfaces work in the same way as the
    default. Implementing this option requires non-standard
    networking APIs and it is only available under Linux. On other
    platforms it falls-back to --bind-interfaces mode. 

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:

# disables dnsmasq reading any other files like /etc/resolv.conf for nameservers

# Interface to bind to

# Specify starting_range,end_range,lease_time

# dns addresses to send to the clients

Hope this helps

Best regards


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .