1.0.3 • Published 5 years ago

ip-subnet-tools v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

##IP Subnet Tools

The ip-subnet-tools allows makes it easier to get the subnet of an ip (24), and an array of all address on that subnet.

Just a test for myself on creating modules for a project, rather than locally linking them.

let subnetTools = require("ip-subnet-tools")

subnet.getSubnet("192.168.0.1");
//will return the subnet of the ip address "192.168.0"
result:

"192.168.0" //string


subnetTools.getNetworkDetails();

//will return an array of network cards with name, 
//address and subnet keys like below.
//result:

[ { name: 'VirtualBox Host-Only Network',
    address: '192.168.56.1',
    subnet: '192.168.56' },
  { name: 'Wi-Fi',
    address: '192.168.115.2',
    subnet: '192.168.115' } ]


subnetTools.getEntireSubnetIps("192.168.2")
//will return an object with key lanIps equal to an array of ip address.
//result:

{ lanIps:
   [ '192.168.2.1',
     '192.168.2.2',
     '192.168.2.3',
     '192.168.2.4',
     '192.168.2.5',
     '192.168.2.6',
     '192.168.2.7',
     '192.168.2.8',
     '192.168.2.9',
     '192.168.2.10',
     '192.168.2.11',
     '192.168.2.12',
     '192.168.2.13',
     '192.168.2.14',
     '192.168.2.15',
     '192.168.2.16',
     .....etc
     '192.168.2.255'
   ]
}

##Installation

$npm install ip-subnet-tools

Will work on making it more flxible in terms of types of subnets using the subnet mask. But currently it does what i need. Cheers.

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago