Exactly the desired configuration of listen-addresses is freely possible since systemd-resolved version 247 (commit 1f05101f and follow-ups) by setting DNSStubListenerExtra
.
Address, port, and protocol (tcp/udp) is configurable multiple times. It's even possible to disable the default listener at (tcp/udp) 127.0.0.53:53 by setting DNSStubListener
to false.
The systemd-resolved configuration-file /etc/systemd/resolved.conf
shows this in it's comments – for instance in ubuntu impish (21.10).
# systemd --version
systemd 248 (248.3-1ubuntu8)
...
# man resolved.conf
...
DNSStubListener=
Takes a boolean argument or one of "udp" and "tcp". If "udp", a DNS stub resolver will listen for UDP requests on address 127.0.0.53 port 53. If "tcp",
the stub will listen for TCP requests on the same address and port. If "yes" (the default), the stub listens for both UDP and TCP requests. If "no", the
stub listener is disabled.
Note that the DNS stub listener is turned off implicitly when its listening address and port are already in use.
DNSStubListenerExtra=
Takes an IPv4 or IPv6 address to listen on. The address may be optionally prefixed with a protocol name ("udp" or "tcp") separated with ":". If the
protocol is not specified, the service will listen on both UDP and TCP. It may be also optionally suffixed by a numeric port number with separator ":".
When an IPv6 address is specified with a port number, then the address must be in the square brackets. If the port is not specified, then the service
uses port 53. Note that this is independent of the primary DNS stub configured with DNSStubListener=, and only configures additional sockets to listen
on. This option can be specified multiple times. If an empty string is assigned, then the all previous assignments are cleared. Defaults to unset.
Examples:
DNSStubListenerExtra=192.168.10.10
DNSStubListenerExtra=2001:db8:0:f102::10
DNSStubListenerExtra=192.168.10.11:9953
DNSStubListenerExtra=[2001:db8:0:f102::11]:9953
DNSStubListenerExtra=tcp:192.168.10.12
DNSStubListenerExtra=udp:2001:db8:0:f102::12
DNSStubListenerExtra=tcp:192.168.10.13:9953
DNSStubListenerExtra=udp:[2001:db8:0:f102::13]:9953
...
This is an explicit answer for easy reference. @TCB13 already stated it as a comment.
systemd-resolved
as a stub resolver? There are any number of established, purpose-made alternatives, including but not limited tobind
,dnsmasq
,unbound
, etc. Note that this is not a rant or mindless hate on the systemd suite. I'd just like to know what prompted you to pick this particular service. Is there any functionality the others don't offer?dnsmasq
andsystemd-resolved
should have abreaks
relationship. And again, why did the distro maintainers make that choice? Seems rather intrusive.