Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-ip-range

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-ip-range

Simple utility to convert either CIDR notation or two IP addresses to an array of the range of IP addresses

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

get-ip-range

All Contributors

Simple utility to convert either CIDR notation, a hyphenated IP range, or two IP addresses to an array of the range of IP addresses.


Build StatusISC License


Installation

$ npm i get-ip-range

Accepted formats

IPv4

  • CIDR "x.x.x.x/x"
  • Range "x.x.x.x-x.x.x.x"
  • Two IPs "x.x.x.x", "x.x.x.x"

IPv6

  • CIDR "x:x:x:x:x:x:x:x/x"
  • Range "::x:x:x-::x:x:x"
  • Two IPs "::x:x:x", "::x:x:x"

N.B. Shorthand IPv6 is supported


Usage

import { getIPRange } from 'get-ip-range';

const ipv4CIDR = getIPRange('192.168.1.134/29');
const ipv4Range = getIPRange('192.168.1.128-192.168.1.135');
const twoIPv4 = getIPRange('192.168.1.128', '192.168.1.135');

// All return:
[
  '192.168.1.128',
  '192.168.1.129',
  '192.168.1.130',
  '192.168.1.131',
  '192.168.1.132',
  '192.168.1.133',
  '192.168.1.134',
  '192.168.1.135',
]

const ipv6CIDR = getIPRange('0:0:0:0:0:ffff:102:304/126');
const ipv6Range = getIPRange('::ffff:102:304-::ffff:102:307');
const twoIPv6 = getIPRange('::ffff:102:304', '::ffff:102:307');

// All return:
[
  '::ffff:102:304',
  '::ffff:102:305',
  '::ffff:102:306',
  '::ffff:102:307',
]

Errors

  • If the supplied IP address(es) are invalid, the request will throw an error. Please handle errors appropriately.
  • If there are more than the default maximum range (10000) or the environment variable (MAX_RANGE) IPs in the range, it will throw an error.

Contributors


Joe Schofield

💻

Miosame

💻

João Antunes

💻

Chingiz Toimbetov

💻

yaniv-checkmarx

🐛

Stanislav Sizonenko

🐛

Keywords

FAQs

Package last updated on 26 Feb 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc