From: Stefan B. <st...@la...> - 2010-05-30 13:38:29
|
Am 30.05.2010 um 11:55 schrieb Frank Lahm: > afair (it's my code so I should remember, but... ;) ) the syntax for > cnid_server is the same as for -ipaddr, ie it's parsed by getaddrinfo. > Afair the use of [] is specd for URLs/URIs, but not for strings passed > to getaddrinfo. > Also note that afaik on all OSen with dual TCP stacks, it should > suffice to listen on "::" in order to accept IPv4 AND IPv6 on this one > listening socket. At least on Linux it does indeed work. That does not appear to be the case in FreeBSD: # grep -v '^#' /usr/local/etc/afpd.conf - -tcp -noddp -ipaddr :: -unixcodepage UTF8 -signature user:freebsd8 -cnid_server ::1 # netstat -an|grep LIST tcp6 0 0 *.548 *.* LISTEN tcp6 0 0 ::1.4700 *.* LISTEN tcp4 0 0 *.6000 *.* LISTEN tcp6 0 0 *.6000 *.* LISTEN tcp4 0 0 127.0.0.1.25 *.* LISTEN tcp4 0 0 *.22 *.* LISTEN tcp6 0 0 *.22 *.* LISTEN The developers handbook has this to say (http://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#IPV6-WILDCARD-SOCKET): > If a server application would like to accept IPv4 and IPv6 connections, there will be two alternatives. > > One is using AF_INET and AF_INET6 socket (you will need two sockets). Use getaddrinfo(3) with AI_PASSIVE into ai_flags, and socket(2) and bind(2) to all the addresses returned. By opening multiple sockets, you can accept connections onto the socket with proper address family. IPv4 connections will be accepted by AF_INET socket, and IPv6 connections will be accepted by AF_INET6 socket. > > Another way is using one AF_INET6 wildcard bind socket. Use getaddrinfo(3) with AI_PASSIVE into ai_flags and with AF_INET6 into ai_family, and set the 1st argument hostname to NULL. And socket(2) and bind(2) to the address returned. (should be IPv6 unspecified addr). You can accept either of IPv4 and IPv6 packet via this one socket. It sounds like the second method should work, but it does not lead to a socket listinging on IPv4, only IPv6. After googling some more, it turns out that FreeBSD disables mapped addresses by default. It can be enabled by setting sysctl net.inet6.ip6.v6only to 0. I'm having trouble finding any discussion of the change (r100676 in the new SVN repository), but it has been the default for over seven years. Stefan -- Stefan Bethke <st...@la...> Fon +49 151 14070811 |