This method takes a string parameter and an optional version
parameter. The string parameter should be a string representation of an IP
address subnet, e.g., 192.0.2.0/24.
The version parameter should be either 4 or 6, but you dont really
need this unless youre trying to force a dotted quad to be interpreted as an
IPv6 network or to a force an IPv6 address colon-separated hex number to be
interpreted as an IPv4 network.
If you pass an IPv4 network but specify the version as 6 then we will add
96 to the netmask.
This method takes an integer parameter, prefix_length parameter, and
an optional version parameter. The integer parameter should be an
integer representation of an IP within the subnet. The prefix_length
parameter should be an integer between 0 and 32 for IPv4 or 0 and 128 for
IPv6. The version parameter should be either 4 or 6.
Note that if you are passing an IPv4 address that you want treated as an IPv6
address you need to manually add 96 to the prefix_length yourself.
Returns a string representation of the network like 192.0.2.0/24 or
2001:db8::/48. The IP address in the string is the first address
within the subnet.
Returns a 4 or 6 to indicate whether this is an IPv4 or IPv6 network.
Returns the length of the netmask as an integer.
Returns the number of bit of an address in the network, which is either 32
(IPv4) or 128 (IPv6).
This returns the maximum possible numeric subnet that this network could fit
in. In other words, the 192.0.2.0/28 subnet could be part of the 192.0.2.0/23
subnet, so this returns 23.
Returns the first IP in the network as an Net::Works::Address object.
Returns the first IP in the network as an integer. This may be a
Returns the last IP in the network as an Net::Works::Address object.
Returns the last IP in the network as an integer. This may be a
This returns an anonymous sub that returns one IP address in the range each
time its called.
For single address subnets (/32 or /128), this returns a single address.
When it has exhausted all the addresses in the network, it returns undef
This method accepts a single Net::Works::Address or Net::Works::Network
object. It returns true if the given address or network is contained by the
network it is called on. Note that a network always contains itself.
This returns a list of two new network objects representing the original
network split into two halves. For example, splitting 192.0.2.0/24 returns
192.0.2.0/25 and 192.0.2.128/25.
If the original networks is a single address network (a /32 in IPv4 or /128 in
IPv6) then this method returns an empty list.
Net::Works::Network->range_as_subnets( CW$first_address, CW$last_address, CW$version )
Given two IP addresses as strings, this method breaks the range up into the
largest subnets that include all the IP addresses in the range (including the
two passed to this method).
This method also excludes any reserved subnets such as the
RFC1918 <http://tools.ietf.org/html/rfc1918> IPv4 private address space,
RFC5735 <http://tools.ietf.org/html/rfc5735> IPv4 special-use address space and
RFC5156 <http://tools.ietf.org/html/rfc5156> IPv6 special-use address space.
An overview can be found at the IANA
special-purpose address registries.
The networks currently treated as reserved are:
This method works with both IPv4 and IPv6 addresses. You can pass an explicit
version as the final argument. If you dont, we check whether either address
contains a colon (:). If either of them does, we assume you want IPv6 subnets.
When given an IPv6 range that includes the first 32 bits of addresses (the
IPv4 space), both IPv4 and IPv6 reserved networks are removed from the