How to convert an address from IPv4 to IPv6

Chris picture Chris · Oct 12, 2009 · Viewed 54.3k times · Source

Is this possible? How can you convert an ipv4 to an ipv6 address?

a few example from here:

0.0.0.0   -> ::
127.0.0.1 -> ::1

I'm searching a solution in Java.

Thanks,

Answer

Yishai picture Yishai · Oct 12, 2009

There is no IPv4 to IPv6 mapping that is meaningful. things like 0.0.0.0 and 127.0.0.1 are special cases in the spec, so they have equivalent meaning. But given an IPv4 address it tells you nothing about what its specific IPv6 address would be. You can use a DNS lookup to see if a given IP address resolves to a host which in turn resolves to an IPv6 address in addition to an IPv4 address, but the DNS server would have to be configured to support that for the specific machine.