An odd IPv6 application issue

George Bonser gbonser at
Sat Dec 11 06:06:34 CET 2010

I have an odd IPv6 application issue and wonder if anyone else has seen
this before.

So imagine I have a machine with both an IPv4 and an IPv6 address on an

Say and 2620:0:5103:1234::3

I have a small java program that I am using for testing.

In /etc/hosts, there is an entry for both the v4 and v6 addresses with
the local hostname.

The issue I am sorting out here is that there are going to be several
IPv6 addresses in real life so I need to tell the application
specifically which one to pick as the source IP when it binds the

So lets say I have:

So I have this little java application and tell it to connect to a
remote host that has only an IPv6 address.  I tell it to bind to

When it does so, it sources traffic from ::ffff:  rather than

It creates an IPv6 socket and communicates with the server via IPv6 but
the source address it selects is the converted v4 address.

If I don't give it a specific local name to bind to, it uses what I
expect.  If I rename the v6 address to something ike, then it works as expected if I also bind the
socket to that name.  In other words, as long as there is only a v6
address associated with the local name, it selects the correct source
IP.  If there are both v4 and v6 IPs associated with a name, it uses the
converted v4 address to source traffic to v6 destinations.  

The problem is that there are going to be several applications in
production on a given server.  Each application must use a different
source IP when it sends traffic out so each application must be
configured with which IP to bind to.  The configuration must be the same
for v4 or v6, I can't tell it "bind to the IP for this name for v6
sockets and bind to the IP for this other name for v4 sockets because I
don't know in advance if I am going to get a v4 or v6 address for the
destination of the socket.  I just need to tell it to connect to
"" using "" as the local address and expect
the OS (Linux in this case) to do the right thing.

This is making dual stacking an application a nightmare.

More information about the ipv6-ops mailing list