dnsmasq : failed to create listening socket for port 53: Address already in use
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.
--bind-dynamic
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:
- dnsmasq, serve different ip addresses based on interface used
- How to avoid conflicts between dnsmasq and systemd-resolved?
More advance related topic:
- How do SO_REUSEADDR and SO_REUSEPORT differ?
- Linux TCP SO_REUSEPORT — Usage and implementation