mobile-shell / mosh

Mobile Shell
https://mosh.org
GNU General Public License v3.0
12.56k stars 729 forks source link

Support roaming between NAT64 and native IPv4 networks #1214

Open achernya opened 2 years ago

achernya commented 2 years ago

I've recently noticed that some wifi deployments are now NAT64 with with DNS64, meaning they have no native IPv4 connectivity, and the NAT64 gateway provides the IPv6 to IPv4 translation.

In particular, when roaming between a native IPv4 network to a NAT64 IPv6 network, mosh never is able to reconnect to an IPv4 server, presumably because all of the sendmsg calls get EHOSTUNREACH (No route to host). Similarly, if the mosh session is started on such a network then roamed to a native IPv4 network, the same applies.

Mosh should detect such networks and automatically switch between the native IPv4 address and the NAT64 address. RFC 7050 specifies how to detect such networks: a DNS AAAA query for ipv4only.arpa , which normally points to 192.0.0.170 and 192.0.0.171, lets you discover the NAT64 prefix.

achernya commented 1 year ago

This is closely related to #212. I think the main difference here is we may want to add some heuristics to enable this even if a general purpose hostname re-resolution feature is protected behind a --enable-roaming flag to the main mosh CLI. The heuristic could be something like "has exactly 1 A record", although admittedly that would still not work for systems that do DNS-based load balancing with short TTLs.