merge-cidrs

1.0.1 • Public • Published

Merge-CIDRs

Given a pair of CIDR blocks, return the smallest CIDR which encompasses both of the original CIDR blocks.

Install with:

npm install merge-cidrs

Usage

var mergeCidrs = require('merge-cidrs');
 
// Using strings (in this example two adjacent /32 CIDR blocks representing the individual IP address)
var subnet = mergeCidrs('127.0.0.1/32', '127.0.0.2/32');
console.log('Merged CIDR: ' + subnet.networkAddress + '/' + subnet.subnetMaskLength);
 
// If you already have ip.cidrSubnets you can use those too. (In this example a /32 and an overlapping /30 CIDR block.)
var subnetA = ip.cidrSubnet('127.0.0.1/32');
var subnetB = ip.cidrSubnet('127.0.0.2/30');
var merged = mergeCidrs(subnetA, subnetB);
console.log('Merged CIDR: ' + merged.networkAddress + '/' + merged.subnetMaskLength);

Readme

Keywords

none

Package Sidebar

Install

npm i merge-cidrs

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • furchin