Net::NetReg::Subnet - Provides services to NetReg for parsing/using IP subnet information
use Net::NetReg::Subnet;
This module provides parsing and testing services for many functions within NetReg. Before a description of the various methods, it is important to understand the how NetReg learns about your network.
NetReg uses a file, subnet.dat, to describe the network. This is somewhat analogous to how a network is described to the DHCP daemon, but with some different information. Besides comment line (lines with a pound sign in column 1) and blank lines, each other line has four colon separated fields. The sample file included in the distribution, subnet.dat.example, describes the format and use of each field:
# Fields followed by colons: # 1. Subnet/mask length for registered clients # 2. Location of subnet # 3. Total number of leases from the subnet for registered clients # 4. Subnet/mask length for unregistered clients if different, # otherwise blank. Note, if you do not specify a different # "subnet" for unregistered clients, active leases for this # subnet (#1 above) will be counted as belonging to unregistered # clients. You should specify a range for unknown clients in # your dhcpd.conf file that be covered a subnet, no matter how # small and regardless of whether it overlaps with the subnet # for registered clients. A trailing colon is optional. # # e.g. # 10.0.64.0/20:Engineering:425:: # 10.0.80.0/23:Residence Hall:448:10.8.80.0/26: # 10.0.96.0/24:Sales:25:192.168.0.0/24: # 10.0.128.0/24:Building 52:127:10.0.128.192/26: #
Subnets are described in CIDR notation. The location field is text descriptive of what the function of that subnet is, or where it is located. The third field is used to scale bar graphs in the administrative CGI Subnet Overview function.
One of the key concepts to understand is the relationship between the listed subnet for registered clients and the one listed for unregistered clients. For accurate statistics it is important that if these two subnets overlap, that the unregistered subnet be defined to cover the ranges used for unknown clients in DHCP. The statistics are gathered from the DHCP leases file, and will be accurate for unregistered clients even if the unregistered subnet includes host entries in your dhcp configuration file that are assigned static addresses, since by default these are not recorded in the leases file. NetReg will let you be lazy here, but be a responsible network administrator, and design your IP address cleanly.
This array stores all possible subnet masks as 32-bit integers. These are used to evaluate...
Registered subnet hash with subnet in decimal form as the key.
Registered subnet hash with subnet in dotted quad form as the key.
Unregistered subnet hash with the registered subnet as key.
The descriptive of subnet location/function.
Given a subnet in CIDR notation, this method will either return undef, if the mask is appropriate for the network, or an error message with the proper mask. This is determined based on whether the provided mask covers all of the bits set to 1 in the network.
Given a 32-bin binary, return the equivalent integer. This method is only used in testing and debugging.
Given an integer, this method will return its 32-bit binary equivalent. This method is only used in testing and debugging.
Given an integer, this method will return its dotted quad IP equivalent.
This method will convert a dotted quad IP address into its 32-bit integer equivalent.
Given an IP address and a network in CIDR notation, this method will return either a 0 (zero) if the IP address is not in that subnet, or a 1 (one) if it is.
Parses the file pointed to by NetReg::Variables::$PATHS{'subnet'} and populates hashes for each distinct NetReg subnet...