Created
October 28, 2015 20:49
-
-
Save wbingli/d903ee7e059d5b742f96 to your computer and use it in GitHub Desktop.
Calculate AWS total IPs
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
require 'open-uri' | |
require 'json' | |
data = JSON.load(open("https://ip-ranges.amazonaws.com/ip-ranges.json")) | |
ip_total = data['prefixes'].reduce(0) do | sum, item | | |
sum += 2 ** (32 - item['ip_prefix'].split('/')[1].to_i) | |
end | |
puts "AWS Total IPs: #{ip_total}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment