Enabling multicast DNS (mDNS) on a server allows other hosts on the local network to address the server as <hostname>.local
.
mDNS is disabled by default in Ubuntu Server:
$ resolvectl mdns
Global: no
Link 2 (eno1): no
mDNS setup involves two config changes:
Multicast DNS will be enabled on a link only if the per-link and the global setting is on.
First, enable mDNS globally in /etc/systemd/resolved.conf
:
[Resolve]
...
MulticastDNS=yes
...
Next, we have to enable mDNS on the network interface. Ubuntu Server uses netplan to render network config files into /run/systemd/network
. But netplan doesn't yet support mDNS configuration, so we need to augment the main network file with a drop-in file.
Determine the name of the main network file:
$ ls /run/systemd/network
10-netplan-eno1.network
Create the drop-in directory based on the name of the main network file:
$ mkdir /etc/systemd/network/10-netplan-eno1.network.d
Create the drop-in file at /etc/systemd/network/10-netplan-eno1.network.d/override.conf
containing:
[Network]
MulticastDNS=yes
Reboot to apply the new configuration.
Verify that mDNS is enabled:
$ resolvectl mdns
Global: yes
Link 2 (eno1): yes
Hmmm, ok.
I have that file like this:
[Resolve]
#Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
#Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
#Google: 8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
#Quad9: 9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
#DNS=10.0.0.138
#FallbackDNS=
#Domains=local
#DNSSEC=no
#DNSOverTLS=no
MulticastDNS=yes
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no
#StaleRetentionSec=0
That should do, right?
But for some reason it is not working. I tried resolvectl status ens3 (which is my interface) and doesnt seem to be activated:
Link 2 (ens3)
Current Scopes: DNS
Protocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported