我尝试使用以下方法获取IPV6地址:
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iface = interfaces.nextElement();
if (iface.isLoopback() && !includeLoopback || !iface.isUp()) {
continue;
}
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress addr = addresses.nextElement();
inetAddresses.add(addr.getHostAddress());
}
}
打印: fe80:0:0:0:250:56ff:fe85:5cb2%eth0
当我执行ifconfig时,它将以下内容作为ipv6地址- fe80 :: 250:56ff:fe85:5cb2 / 64
我在哪里想念? 帮助将不胜感激。 谢谢!
答案 0 :(得分:0)
IPV6标准说:
::等于:0:0:0: