Feed on
Posts
Comments

If you’re like me, you have a home LAN filled with various contraptions, computers, mobile devices and the ubiquitous server in the closet. Usually there’s no DNS zone containing your home devices, if anything, maybe a static /etc/hosts entry on your desktop to give a short hostname to your closet server. Otherwise, people just use the IP address of the device. Chances are if you’ve setup a home network, memorizing the subnet (e.g. 192.168.130.0/24) is pretty easy, it’s just a matter of knowing that .10 is closetserver, .15 is your XBOX, and so forth. You just “ssh 192.168.130.10” and you’re good.

When devices have IPv6 addresses, using the IP address isn’t feasible anymore. There has to be some sort of name lookup mechanism. It’s just too long to remember an IPv6 address and there are fiddly things to watch for. Nobody is going to run a real DNS server in their house either.

In the simplest case of using only link-local addresses, you’re just not going to remember your closetserver is fe80::216:e6ff:fed8:d122. You can put a host entry on your desktops, but this involves updating everything by hand. Link-local addressing also presents an additional challenge in that if you have a computer with multiple interfaces (think: laptop with a gigabit LAN interface and a 802.11 wireless interface), you have to specify the interface to use in your /etc/host entry, i.e.

fe80::216:e6ff:fed8:d122%en1  closetserver

This would tell your application to use the en1 (wireless) interface to get to closetserver.  But, if you turn off your wireless and plug into your switch, all of a sudden en1 is the wrong interface to use. Now you have to go edit /etc/hosts again to change from %en1 to %en0.

A slightly more advanced example is if your home network uses your router (in my case an Apple Airport Extreme) as a 6to4 gateway.  The IPv6 address is still to long to remember, but now the network prefix can change based on your externally visible IP address.  Today closetserver may be 2002:4770:2e84::216:e6ff:fed8:d122. Tomorrow your cable modem may reset, giving you a different dynamic IPv4 address and thus a different 6to4 prefix. Now closetserver’s address has changed to 2002:4778:1156::216:e6ff:fed8:d122, and you need to go update all those /etc/host entries.

Solution: Multicast DNS (mDNS). Also known in some documents as “serverless DNS”.

It turns out there’s at least already one solution for all this running behind the scenes that I wasn’t aware of, Multicast DNS. This part of what Bonjour/Zero-conf networks are built on. Each device joins a multicast group on your LAN, advertising and responding to name lookups without contacting an external DNS server or /etc/hosts.

Almost all Apple OS X and iOS devices already have Multicast DNS (mDNSResponder) running, which is how things like iTunes sharing and streaming work, and lets me access resources on the network via name such as “firecracker” for my desktop without knowing the IP address. On Linux, this is handled by Avahi. On Windows, it’s Bonjour for Windows.

This isn’t strictly a problem with just IPv6 either, and there are probably other things out there that do this. This is most interesting to me because the majority of my devices are Apple products.

Here’s how it works:

From my laptop, I want to ssh to closetserver (which is running Avahi). In order to use mDNS, I need to use a “.local” suffix:

lapdance:~ bwann$ ssh -6 closetserver.local

My laptop queries the mdns multicast address ff02::fb on port 5353 asking anyone for a AAAA record of closetserver.

16:01:20.585290 IP6 lapdance.local.mdns > ff02::fb.mdns: 0 AAAA (QM)? closetserver.local. (30)

The mDNS responder on closetserver responds to the multicast group with the AAAA record to use.

16:12:12.098910 IP6 2002:4770:2e84::216:e6ff:fed8:d122.mdns > ff02::fb.mdns: 0*- [0q] 2/0/0 (Cache flush) AAAA 2002:4770:2e84::216:e6ff:fed8:d122 (80)

Then the ssh program initiates the usual TCP with closetserver and we’re done:

16:16:33.518129 IP6 2002:4770:2e84::216:cbff:fe09:a76e.60425 > 2002:4770:2e84::216:e6ff:fed8:d122.ssh: Flags [S], seq 832255505, win 65535, options [mss 1440,nop,wscale 2,nop,nop,TS val 1053744031 ecr 0,sackOK,eol], length 0

Now if I change from wireless to wired, change my external IPv4 address, or even use a new desktop, I can still use the same hostnames without changing anything.  Neat!  This would also be useful for ad-hoc networks as well.

Men & Mice has a great presentation describing Multicast DNS.

Leave a Reply