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

netmask

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netmask

Parse and lookup IP network blocks

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.1M
increased by0.44%
Maintainers
1
Weekly downloads
 
Created

What is netmask?

The netmask npm package is used for parsing and manipulating network addresses (IPv4 and IPv6). It allows for operations such as parsing CIDR notation, calculating network ranges, subnetting, and checking if an IP address is part of a network. This package is particularly useful for network-related programming tasks, security analysis, and systems administration.

What are netmask's main functionalities?

Parsing and creating netmasks

This feature allows for the creation of netmask objects by parsing CIDR notation. It enables the extraction of the base address and the subnet mask.

const { Netmask } = require('netmask');
const block = new Netmask('192.168.1.0/24');
console.log(block.base); // '192.168.1.0'
console.log(block.mask); // '255.255.255.0'

Checking if an IP is within a subnet

This functionality enables checking whether a specific IP address falls within a defined subnet, which is useful for network security and management.

const { Netmask } = require('netmask');
const block = new Netmask('192.168.1.0/24');
console.log(block.contains('192.168.1.123')); // true
console.log(block.contains('192.168.2.123')); // false

Iterating over all IPs in a subnet

This feature allows for iterating over each IP address within a subnet. It's particularly useful for network scanning or allocation tasks.

const { Netmask } = require('netmask');
const block = new Netmask('192.168.1.0/30');
block.forEach(ip => console.log(ip));

Other packages similar to netmask

Keywords

FAQs

Package last updated on 20 Mar 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