ip-subnet-tools
v1.0.3
Published
Easily get network addresses and subnet lists
Downloads
2
Readme
##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.