Convert CIDR notation to IP range in Java
•
Java
See the English answer > converting CIDR address to subnet mask and network address 11
For example, for CIDR 192.168 1.0/16, the output shall be 192.168 0.0 to 192.168 255.255. But I got 192.168 0.1 to 192.168 255.254.
Please help
Solution
By default, the subnetutils class excludes the 0th and last addresses from the available host address range because they (or in the case of the 0th address) are used as webcast addresses
You need to call on the subnetutils instance Setinclusivehostcount (true) method to tell it to include these addresses in the returned range
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码