-
-
Save richorama/53b7285398f89308f55d to your computer and use it in GitHub Desktop.
Count the public IP addresses in each of the Azure DCs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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