Java and IPv6 on BSD - it does not work well

Frank Behrens frank at harz.behrens.de
Fri Oct 17 07:10:23 UTC 2008


Kurt Miller <kurt at intricatesoftware.com> wrote on 16 Oct 2008 22:41:
> The networking support in the BSD port is based on the linux/solaris
> code. When compiled with IPv6 support enabled the JDK uses only IPv6
> sockets and relies on IPv4 to IPv6 address mapping. For security
> reasons all BSD's have v4mapped addresses turned off by default. If
> you want both IPv6 and IPv4 support in the jdk on FreeBSD you must
> 1) compile the JDK with IPv6 support, 2) change the
> net.inet6.ip6.v6only sysctl to 0 using sysctl or via /etc/sysctl.conf,
> and 3) Use only IPv6 addresses and special addresses as described in:

I agree and 3) is the main problem. You can only use the special 
addresses.

> What really needs to happen is to port the Windows approach in
> the JVM to BSD. On Windows two sockets are created per ServerSocket;
> one for IPV6 and another for IPv4. This avoids the need to use

We should distinguish between two use caes:

a) I want to use the "transparent and automatic" IPv6 support in 
Java. That means I create one server socket and want to be able to 
receive IPv4 and IPv6 packets.
That works in Java for INADDR_ANY and IPV6_V6ONLY=0.
For other addresses and/or IPV6_V6ONLY=1 you need two server sockets 
(Windows approach).

BTW: It was not a surprise for me to see problems with a), it is a 
special case.

b) I want to listen with a socket to a specific IPv6 address and with 
another socket to a specific IPv4 address. A special case? Not for 
other programming languages.
In this case the Java runtime creates always an IPv6 socket and later 
tries to bind with an IPv4 or IPv6 address - of course it will fail 
for IPv4. Here the solution should be: At first determine the address 
type and create later the socket with right address family.

I wonder, that I did not find error reports about this issue. Did 
nobody discover, that listening to "localhost" does not work on an 
IPv6 enabled system?

-- 
Frank Behrens, Osterwieck, Germany
PGP-key 0x5B7C47ED on public servers available.



More information about the freebsd-java mailing list