6

I'm creating a custom distribution where I need a DNS responder. I'm already using systemd so I would like to use systemd-resolved to manage mDNS (the device should announce itself as capable of a couple of services); I'm not sure whether or not this is possible, but the systemd-resolved documentation pages reports

systemd-resolved is a system service that provides network name resolution to local applications. It implements [...] MulticastDNS resolver and responder.

I already added set MulticastDNS=yes in the configuration file, as well as under the [Network] section of the interfaces where I want mDNS to be enabled (I can verify that with systemd-resolve --status eth0).

However, I'm not able to understand how to configure the available services to be announces, as it was done with avahi by adding them in /etc/avahi/services.

Are there any other configuration file for systemd-resolved? Is this not possible at all?

1 Answer 1

8

The capability of using mDNS should be enabled in the /etc/systemd/resolved.conf file, in the [Resolve] section, by setting MulticastDNS=yes. Moreover, it should be enabled in the [Network] section of each interface configuration file (the one for systemd-network) by setting MulticastDNS=yes.

The status of the MulticastDNS setting can be verified with:

~# systemd-resolve --status
Global
           Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
    resolv.conf mode: uplink
Fallback DNS Servers: 1.1.1.1#cloudflare-dns.com 8.8.8.8#dns.google 1.0.0.1#cloudflare-dns.com 8.8.4.4#dns.google 2606:4700:4700::1111#cloudflare-dns.com 2001:4860:4860::8888#dns.google 2606:4700:4700::1001#cloudflare-dns.com
                      2001:4860:4860::8844#dns.google

Link 2 (eth0)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6 mDNS/IPv4 mDNS/IPv6
     Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 3 (enp1s0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported

For each interface, +mDNS means that MulticastDNS is enabled in that interface. Global refers to the systemd-resolved global configuration.

Services can be configured by creating /service/.dnssd files with the following format:

[Service]
Name=%H
Type=_http._tcp
Port=80
TxtText=path=/stats/index.html t=temperature_sensor

see https://www.freedesktop.org/software/systemd/man/systemd.dnssd.html for more informations.

Configuration files can be saved in:

  • /etc/systemd/dnssd
  • /run/systemd/dnssd
  • /usr/lib/systemd/dnssd
3
  • 1
    Can you give example of dnssd for sftp, ssh, smb broadcast ? Commented May 28, 2023 at 8:09
  • worked for me by only specifying multicast in global congig of resolved, after sudo systemctl restart systemd-resolved. nsswitch.conf is not updated but resolution seems to work, perhaps silently done by systemd-resolved. Commented Mar 19, 2024 at 10:25
  • this is gonna be mangled, but this worked for me for my samba share: [Service] Name=My Samba Share Type=_smb._tcp Port=445 TxtData=path=/storage .. then bounced systemd-resolved. Commented Apr 10 at 16:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.