Zeroconf networking
Zeroconf networking lets you assign .local domain names to hosts on your local network without running a DNS server.
There are two major aspects of zeroconf networking:
- Multicast DNS (how do I publish my IP address as example.local?)
- Service discovery (what HTTP/TCP/whatever services are on my local network?)
Multicast DNS
Multicast DNS (mDNS) is how this works. In short, it’s DNS over multicast UDP. To resolve xyz.local, the client spams the DNS lookup request to everyone on the local network via multicast. The host for xyz.local spams a multicast message back with its IP and port. Any other hosts that happen to be listening can take note and update their own caches.
Service discovery
Being able to resolve xyz.local is great, but how do you know that xyz.local exists and has something you’re interested in? This is where service discovery comes in—the ability to query the network for services of interest.
DNS-SD is one such solution. I don’t know much about it—need to do more reading.
Setting it up
Install Avahi. Write a small XML file to advertise your machine at a given .local address. It provides mDNS and DNS-SD, and is installed out of the box on Ubuntu and Debian. The Ubuntu documentation is good, as is the Arch wiki.
iOS and Mac probably have mDNS working out of the box, because this is how iTunes has been working since forever (see Bonjour). My iPhone running Safari is able to resolve .local URLs on my local wifi network to my Raspberry Pi which runs Avahi. At time of writing, Windows support has been lagging, but catching up (maybe).