Skip to content

Instantly share code, notes, and snippets.

@jimmydo
Last active March 20, 2025 15:10
Show Gist options
  • Save jimmydo/e4943950427234408a1aaa2d7beda8b6 to your computer and use it in GitHub Desktop.
Save jimmydo/e4943950427234408a1aaa2d7beda8b6 to your computer and use it in GitHub Desktop.
Enable multicast DNS on Ubuntu Server

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
@FlorianHeigl
Copy link

FlorianHeigl commented Feb 7, 2025

the f... why would you need to reboot for restarting a service... don't let this stuff (*) mislead you. you never need to reboot unix.

("it" being the software and the interfaces it provides you, not the gist. The gist is great)

@cdalexndr
Copy link

after reboot I cannot access my remote server with ssh... this script is missing some pre checks

@brodo
Copy link

brodo commented Mar 18, 2025

@cdalexndr I had the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment