Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Count the public IP addresses in each of the Azure DCs
var xml2js = require('xml2js');
var fs = require('fs');
var Netmask = require('netmask').Netmask;
// download from here http://www.microsoft.com/en-gb/download/details.aspx?id=41653
var xml = fs.readFileSync('ip-ranges.xml').toString();
xml2js.parseString(xml, function(err, json){
var output = {};
var total = 0;
json.AzurePublicIpAddresses.Region.forEach(function(x){
output[x.$.Name] = 0;
x.IpRange.forEach(function(z){
var block = new Netmask(z.$.Subnet);
//console.log(block);
output[x.$.Name] += block.size;
total += block.size;
});
});
console.log(output)
console.log(total)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.