Skip to content

How to get netmask? #2263

Answered by dbwiddis
ViniScardoso asked this question in Q&A
Discussion options

You must be logged in to vote

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 class getInterfaceAddresses() method. The values come from getNetworkPrefixLength().

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ViniScardoso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants