本文介绍了getNetworkPrefixLength()返回奇怪的子网掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码:
InetAddress localHost = Inet4Address.getLocalHost();
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localHost);
for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
System.out.println(address.getAddress() + "/" + address.getNetworkPrefixLength());
}
返回:
/fe80:0:0:0:11da:433a:412a:8c23%13/64
/192.168.1.107/128
我的子网掩码是/ 24,而不是/ 128。这是一个Java错误吗?
My subnet mask is /24, not /128. Is it a Java bug?
推荐答案
也许你遇到了这个错误:
Maybe you hit this bug: http://bugs.sun.com/view_bug.do?bug_id=6707289
(请停止upvote ...这只是1 google go ...)
(Please stop to upvote ... this was only 1 google away ...)
这篇关于getNetworkPrefixLength()返回奇怪的子网掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!