-
-
Save mkyung/92a0db55af3c8e74286eedc93c289a50 to your computer and use it in GitHub Desktop.
Calculate AWS total IPs
This file contains hidden or 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