Converting CIDR address to subnet mask and network address

前端 未结 11 710
既然无缘
既然无缘 2020-11-29 01:32

Given a CIDR address, e.g. 192.168.10.0/24

  • How to determine mask length? (24)
  • How to determine mask address? (255.255.
11条回答
  •  萌比男神i
    2020-11-29 01:45

    Following Yuriy's answer: To get the whole range of ip addresses, the Apache Java class SubnetUtils offers the following methods:

    String[] addresses = utils.getInfo().getAllAddresses();
    

    To download the jar containing the class go to: http://repo1.maven.org/maven2/commons-net/commons-net/3.0.1/commons-net-3.0.1.jar

    The source code: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/SubnetUtils.java?view=markup

    Maven id:

    commons-net
    commons-net
    3.0.1
    

提交回复
热议问题