Mac – How does Back To My Mac work without UPnP or NAT-PMP

back-to-my-macipv6Networktunnel

Back To My Mac (BTMM) used to require UPnP or NAT-PMP on your router to work, but at some point this changed and it can work (albeit slowly) without those.

BTMM (usually?) works by setting up an encrypted IPv6 tunnel over IPv4 between the two hosts, and with UPnP/NAT-PMP, the appropriate ports are forwarded on the router at each end, allowing a direct connection.

But how does it work when there's no UPnP/NAT-PMP?

I noticed that it's much slower if either end doesn't have UPnP/NAT-PMP (I get a ~40ms ping if both ends have the automatic config, and about 1000ms if they don't), so I'm wondering where the traffic goes — presumably it has to go via Apple servers if a direct connection can't be automatically negotiated?

But even with just plain old NAT, is it not possible for a 3rd party to arbitrate a connection between two NAT'ed hosts?

Is there a way to tell how that IPv6 tunnel is getting set up? I can't figure it out from the output of ifconfig, traceroute, traceroute6, netstat or lsof

For bonus points, is it possible to set up static port forwards on a router that lacks UPnP/NAT-PMP in order to get BTMM working directly, rather than in this slower mode?

Best Answer

You probably already read did-you-realize-apples-back-to-my-mac-mobileme-service-uses-ipv6 by now. It has some of the answers. Also https://en.wikipedia.org/wiki/KAME_project I don't know how much was changed since MobileMe became iCloud.

lsof -i:4500 Shows that the process 'racoon' is handling the tunnel. This port is also opened on the router.

I wonder what it does with mdsDirectory.db. Also, it would be nice if BTMM worked also without tunneling and instead used native IPv6 when possible.