networker
design your own ipv4/6 networks
why
mostly educational - trying to teach myself about ip routing and most of the subnet calculators out there are pretty confusing
how
see CIDR
example
var networker = ; // i got a /48 from hurricane electricvar block = ; // let's split that in halfvar net49 = block;console; // 2 // maybe we're designing a big company network and we want// to reserve some addresses for internal vs external usevar internal = net49;var external = net49;// var moar = net49.network(2); // you can try this, but you will get a RangeError // perhaps we'd like to split up our internal network into two smaller ones:var internal = internal; // and in turn split those out into /64s for assignment to employees and equipment respectivelyvar employees = internal;var equipment = internal;console; // 16384console; // great, now let's reserve a couple for dedicated equipmentvar printserver = equipment;var refrigerator = equipment;var jukebox = equipment;console; // here we are picking a random full address from the networkconsole; // here we are just printing the network prefixconsole; // and we can pick at random from a safe range of remaining equipment addressesconsole;console;console;
api
networker(address, [prefixLength, [networkSize=entireNetwork]])
create a new networkn.subnet(networkSize)
split a network into subnets usingnetworkSize
bitsn.size()
show the number of subnets in a networkn.network([index])
select a random subnet or pick one at a specific indexn.address([lowerIndex, [higherIndex]])
select a random subnet in the given rangen.toString()
string representation of the network address
test
none yet.. but the example above can be run by doing node example
notes
- the example uses ipv6, but ipv4 works the same way
license
WTFPL