且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将地址从IPv4转换为IPv6

更新时间:2023-02-11 13:19:05

没有有意义的IPv4到IPv6映射。像0.0.0.0和127.0.0.1这样的东西是规范中的特例,所以它们具有相同的含义。但是考虑到IPv4地址,它不会告诉您具体的IPv6地址是什么。您可以使用DNS查找来查看给定的IP地址是否解析为主机,而该主机除了IPv4地址之外还可以解析为IPv6地址,但DNS服务器必须配置为支持特定计算机的IP地址。 / p>

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,

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.