🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

subnet-cidr-calculator

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subnet-cidr-calculator

JavaScript class for calculating all possible subnets, subnet validity, ip range

latest
Source
npmnpm
Version
1.0.12
Version published
Weekly downloads
2.5K
-23.47%
Maintainers
1
Weekly downloads
 
Created
Source

subnet-cidr-adviser

=================

JavaScript class for calculating all possible subnets, subnet validity, ip range

Buy Me A Coffee

What does it do?

  • Calculates all possible subnets within the given vpc.

  • Calculates IP range available within each of the subnet.

  • Calculates if subnet you are trying to create is already taken or overlapping with existing subnet (you need to provide a list of existing subnets).

  • Suggest next possible subnet (you need to provide a list of existing subnets).

  • Takes a Subnet CIDR network address and returns information ( all hosts, start address, end address)

Download

Demo

Support

  • Node.js
  • ... in progress

Installation

> bower install subnet-cidr-calculator

> npm install subnet-cidr-calculator

Node.js

var SubnetCIDRAdviser = require( 'subnet-cidr-calculator' );

var existingSubnetCIDR = ['10.0.32.0/19'];
var probabal_subnets = SubnetCIDRAdviser.calculate('10.0.0.0' , '16', existingSubnetCIDR);
var is_overlap = SubnetCIDRAdviser.isSubnetOverlap(existingSubnetCIDR, '10.0.32.0/20');
console.log(is_overlap, 'subnetOverlap');
var ip_range = SubnetCIDRAdviser.getIpRangeForSubnet( '10.0.32.0/20' );
console.log('IP range for 10.0.32.0/20 is', ip_range);

var subnetdetails = SubnetCIDRAdviser.getSubnetDetails( '10.0.32.0/20' );
console.log('Details for 10.0.32.0/20 is', subnetdetails);

var parentVPC_CIDR = '10.0.0.0/16';
var cidrToValidate = '';
var getNextValidCIDR = SubnetCIDRAdviser.getNextValidCIDR( parentVPC_CIDR, existingSubnetCIDR, probabal_subnets, cidrToValidate );
console.log('getNextValidCIDR is', getNextValidCIDR);

RequireJS

require( [ 'ip-subnet-calculator' ],

function( SubnetCIDRAdviser )
{
   console.log( SubnetCIDRAdviser.calculate( '10.0.0.0', '16', existingSubnetCIDR ) ); 
} );

Direct browser use

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="./lib/SubnetCIDRAdviser.js"></script>
<script type="text/javascript">
  var existingSubnetCIDR = ['10.0.32.0/19'];
  var probabal_subnets = SubnetCIDRAdviser.calculate('10.0.0.0' , '16', existingSubnetCIDR);
  var is_overlap = SubnetCIDRAdviser.isSubnetOverlap(existingSubnetCIDR, '10.0.32.0/20');
  console.log(is_overlap, 'subnetOverlap');
  var ip_range = SubnetCIDRAdviser.getIpRangeForSubnet( '10.0.32.0/20' );
  console.log('IP range for 10.0.32.0/20 is', ip_range);


  var subnetdetails = SubnetCIDRAdviser.getSubnetDetails( '10.0.32.0/20' );
  console.log('Details for 10.0.32.0/20 is', subnetdetails);


  var parentVPC_CIDR = '10.0.0.0/16';
  var cidrToValidate = '';
  var getNextValidCIDR = SubnetCIDRAdviser.getNextValidCIDR( parentVPC_CIDR, existingSubnetCIDR, probabal_subnets, cidrToValidate );
  console.log('getNextValidCIDR is', getNextValidCIDR);

API

SubnetCIDRAdviser.calculate( '10.0.0.0', '16', existingSubnetCIDR )

Calculates all possible subnets within the given vpc ... in progress.. more to come... :)

Keywords

subnet

FAQs

Package last updated on 10 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts