The following code:
InetAddress localHost = Inet4Address.getLocalHost();
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localHost);
for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
System.out.println(address.getAddress() + "/" + address.getNetworkPrefixLength());
}
returns:
/fe80:0:0:0:11da:433a:412a:8c23%13/64
/192.168.1.107/128
My subnet mask is /24, not /128. Is it a Java bug?
Maybe you hit this bug: https://bugs.java.com/bugdatabase/view_bug?bug_id=6707289
(Please stop to upvote … this was only 1 google away …)