As used by Apple’s Bonjour implementation of the Zeroconf networking stack.
If using Debian or the like, just apt install avahi-daemon and libnss-mdns, and access your hosts on the local network as servername.local.
If your router's default configuration is sane it should (by default) only allow returning connections and drop any other.