FoldingAtHome / fah-issues

49 stars 9 forks source link

Client doesn't work on NAT64/DNS64 networks #1682

Open Frankkkkk opened 2 years ago

Frankkkkk commented 2 years ago

Your Environment


Expected Behavior

NAT64/DNS64 enables IPv4 connectivity to IPv6 only hosts. When a v6-only host needs to reach a v4-only host, it will make a DNS request to its hostname. The DNS64 server will reply with a specific v4-in-v6 encoded IPv6.

This enables IPv6 only hosts to talk with IPv4 only servers. DNS64/NAT64 is increasingly used everywhere as some providers now only give IPv6s and rely on the NAT64 infrastructure for the v4-only stuff.

the fahclient doesn't work on this infrastructure.


Current Behavior

The client enforces the connection in IPv4 whereas it should use, by priority, unless specified otherwise in the gai.conf file, IPv6 addresses.

In this setup, we see that the DNS server correctly gives an IPv6 for the hosts:

root@fah-gnf7p:/opt/fahclient# host assign1.foldingathome.org
assign1.foldingathome.org has address 65.254.110.245
assign1.foldingathome.org has IPv6 address 64:ff9b::41fe:6ef5

and we can see that the NAT64 works:

root@fah-gnf7p:/opt/fahclient# curl -v assign1.foldingathome.org
*   Trying 64:ff9b::41fe:6ef5:80...
* Connected to assign1.foldingathome.org (64:ff9b::41fe:6ef5) port 80 (#0)
> GET / HTTP/1.1
> Host: assign1.foldingathome.org
> User-Agent: curl/7.74.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 HTTP_OK
< Date: Mon, 28 Feb 2022 09:22:01 GMT
< Content-Length: 71432
< Content-Type: text/html; charset=UTF-8
< 
<!DOCTYPE html>
<html>
  <head>
    <title>Folding@home Assignment Server - v5.0.3</title>
    <!-- There's nothing to see here.  Move along, move along... -->
   --- snip ---

however the client, when doing the resolution internaly, only uses v4 addresses:

root@boinc-gnf7p:/opt/fahclient# strace ./FAHClient 
# DNS resolution works
socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 3
setsockopt(3, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
connect(3, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "2001:1600:caca:50da:1b:fffe:0:a", &sin6_addr), sin6_scope_id=0}, 28) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
sendto(3, "\324\346\1\0\0\1\0\0\0\0\0\0\7assign3\rfoldingatho"..., 79, MSG_NOSIGNAL, NULL, 0) = 79
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [202])               = 0
recvfrom(3, "\324\346\205\3\0\1\0\0\0\1\0\0\7assign3\rfoldingatho"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "2001:1600:caca:50da:1b:fffe:0:a", &sin6_addr), sin6_scope_id=0}, [28]) = 202
close(3)                                = 0

# However socket fails, as it uses IPv4:
write(1, "09:07:34:Connecting to assign1.f"..., 5109:07:34:Connecting to assign1.foldingathome.org:80) = 51
write(1, "\n", 1
)                       = 1
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("65.254.110.245")}, 16) = -1 ENETUNREACH (Network is unreachable)
futex(0xbe8390, FUTEX_WAKE_PRIVATE, 2147483647) = 0
close(3)                                = 0

Possible Solution (Optional)

Rely on the host's gai.conf preferences and allow IPv6 connections


Steps To Reproduce

See above


Context

As-is, FAH will not work on a NAT64 infrastructure. I'd like to install fah on my clusters but sadly it doesn't work because of the aforementioned problem :( .

As an example, Apple mandates supporting DNS64/NAT64 infrastructures (details here.

Personally, I don't see a reason to force the IPv4 connection. It made sense in the past (~10 years ago) when many networks where badly configured and offered a broken IPv6. However, today this is not the case anymore

Thanks and cheers !