How to get netmask? #2263
-
Hi, I'm trying to get the ipv4 and ipv6 netmasks but the only method that I found was "getSubnetMasks" but it returns a Short value. Does anyone know how to properly get this informations? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @ViniScardoso ... the netmasks are between 0 and 32, as you would see in CIDR notation. So a value of 32 corresponds to a mask of 255.255.255.255. A value of 31 would be 255.255.255.254. A value of 24 would be 255.255.255.0. And so on. The IPv6 prefix lengths are treated similarly, but are between 0 and 128. These fields are pulled directly from the interfaces iterated in Java's |
Beta Was this translation helpful? Give feedback.
Hey @ViniScardoso ... the netmasks are between 0 and 32, as you would see in CIDR notation.
So a value of 32 corresponds to a mask of 255.255.255.255. A value of 31 would be 255.255.255.254. A value of 24 would be 255.255.255.0. And so on.
The IPv6 prefix lengths are treated similarly, but are between 0 and 128.
These fields are pulled directly from the interfaces iterated in Java's
NetworkInterface
classgetInterfaceAddresses()
method. The values come fromgetNetworkPrefixLength()
.