CIDR calculation functions to simplify complex network maps. Heavily influenced by the functions available in Terraform. However, these only support IPv4. IPv6 might be supported later if there is sufficient demand.
npm i @sophosoft/hard-cidr
An enum is provided for the RFC 1918 private address ranges. These are best used when calculating an enterprise network map of non-overlapping subnets across multiple data centers, accounts, regions, and/or availability zones.
RFC_1918.CLASS_A // 10.0.0.0/8RFC_1918.CLASS_B // 172.16.0.0/12RFC_1918.CLASS_C // 192.168.0.0/16
Calculate a single subnet from a given CIDR range and additional bits, with an optional index.
Calculate a sequence of non-overlapping, non-gapped subnets from a given CIDR range
// [10.1.0.0/19, 10.1.32.0/23, 10.1.34.0/25, 10.1.34.128/25]
Calculate a single host ip from a given CIDR range