min-prefix-length

1.0.0 • Public • Published

min-prefix-length Build Status XO code style

Calculate the minimum prefix length for an IPv4 subnet based on a desired number of host accounting for broadcast and network addresses

minPrefixLength(8) => 28

Install

$ npm install --save min-prefix-length

Usage

const minPrefixLength = require('min-prefix-length');
 
const prefix = minPrefixLength(28);
const CIDR = `192.168.1.0/${prefix}`
console.log(CIDR)
// => "192.168.1.0/28"

API

minPrefixLength(n)

Returns the minimum prefix length needed to support n of hosts accounting for the network and broadcast address

n | <number>

n number of desired hosts

Related

💻 - min-host-bits - Calculate minimum host bits needed for desired number of hosts

License

MIT © Brandon Him

Readme

Keywords

none

Package Sidebar

Install

npm i min-prefix-length

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • brh55