0

I have a scenario to find all the ipv4 addresses amazon web services is having (assuming I have ip-ranges.json stored locally) then parse through the json to get total number of ip-adresses available for ipv4 and how many ipv4 adresses are there for a particular region. Is there any way to do that.

code:

import requests

IP = 'http://ip-ranges.amazonaws.com/ip-ranges.json'

ranges = requests.get(IP).json()

services = {}
for prefix in ranges['prefixes']:
print prefix
Alex
  • 189
  • 3
  • 21
  • 1
    StackOverflow isn't a code-writing service, but what you've described isn't hard. The `ip_prefix` values will tell you how many addresses each block has (a `/15` block will have 2^17 addresses, for example) so you can just load the JSON using the `json` library and iterate through the values. – Brian Sep 19 '17 at 15:38
  • 1
    If you're struggling to do this then take a look at https://python-iptools.readthedocs.io/en/latest/. – jarmod Sep 19 '17 at 15:48
  • AWS has a limited range of public IPs: https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html – hjpotter92 Sep 19 '17 at 15:53
  • @Brian i have tried the same can you help here I am pretty new to python., whatever I am trying is not giving me the results. I have posted my code as edit 1 – Alex Sep 19 '17 at 15:59
  • any help will be fine :-) – Alex Sep 20 '17 at 05:11

0 Answers0