How to enable “.local” lookups for uCore?

I don’t know exactly what this feature is called (mDNS, Avahi, Zero-conf?), but I’m looking to enable whatever it is that allows computers on a home LAN to find each other by “.local” hostnames. Example the computer named “bob” can be found using “bob.local”.

This is a handy feature to have on simple home networks without static IPs or fancy routers or DNS services.

Specifically, I would like for my uCore server to be locatable in this way.

Maybe it’s enabled already and I just need to poke the right holes in the firewall, or maybe I need to add something? Any pointers would be appreciated.

In order for that to work you’ll need a router that supports that type of DNS.
What you’re looking for is usually handled by either your DNS or DHCP servers, respectively.

Fancy routers? What does that constitute? :smiley: Purely for clarification.
There is a setting called hostnamectl that will let you configure these things, and if you have a network that supports it, the broadcast will happen automatically.

You don’t need a fancy router or possibly any router at all. I think you just need Avahi service enabled: Avahi - ArchWiki

Or maybe even systemd-resolved can work with mDNS, haven’t tried it as I don’t use mDNS myself.

Fancy routers? What does that constitute? :smiley: Purely for clarification.

I meant that I have a boring domestic home router, nothing advanced that lets me configure DNS records. I mentioned it because I was looking to enable whatever the automatic “the host broadcasts or responds itself” - and not have someone tell me to add DNS entries in my DNS server.


Thanks for the suggestion to look at systemd-resolved. That was very simple to get going, and didn’t require that I install anything like Avahi. Here is what worked for me.

First, use systemctl status to confirm that you are using systemd-resolved, and check with systemd-resolve --status to see the current status of mDNS. Here is an example fragment of the output. The -mDNS piece means that mDNS is disabled:

Link 2 (eno1)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
         Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.4.1
       DNS Servers: 192.168.4.1
     Default Route: yes

Confirm that your host has a hostname configured:

$ hostnamectl hostname
box

Create or edit the file /etc/systemd/resolved.conf, ensure this is present:

[Resolve]
MulticastDNS=true

Restart systemd-resolved:

sudo systemctl restart systemd-resolved

The systemd-resolve --status command should now show +mDNS. Example:

Link 2 (eno1)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 mDNS/IPv4 mDNS/IPv6
         Protocols: +DefaultRoute LLMNR=resolve +mDNS -DNSOverTLS DNSSEC=no/unsupported
       DNS Servers: 192.168.4.1
     Default Route: yes

Confirm via another machine on the network (previously this was failing to resolve!):

> ping box.local
PING box.local (192.168.5.31): 56 data bytes
64 bytes from 192.168.5.31: seq=0 ttl=64 time=5.742 ms
64 bytes from 192.168.5.31: seq=1 ttl=64 time=4.953 ms
64 bytes from 192.168.5.31: seq=2 ttl=64 time=5.849 ms

Done!

Some documentation I found stated that MulticastDNS would need to be enabled not just at this “global” level, but at the “per-link” level too. I did not find that to be true - the global setting was enough in my case.