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
@gkapellmann yeah, if network is managed by
systemd-networkd
, then you need to create a drop-in setting to enable mDNS explicitly as defined above.netplan status
tells if an interface is managed byNetworkManager
ornetworkd
.On one of my hosts (with
ubuntu-desktop
component):On another host (without
ubuntu-desktop
component):Note that I had to explicitly stop and disable
systemd-networkd
service after I installedubuntu-desktop
. So ifsystemd-networkd
is active it's not necessarily meansnetworkd
manages the network.On the first host managed by
NetworkManager
it's sufficient to only change/etc/systemd/resolved.conf
and restartsystemd-resolved
.On the second host there's a need to create a
override.conf
as described in the gist and restart bothsystemd-resolved
andsystemd-networkd
. A reboot is not mandatory to apply the changes.