Filter IPs coming from AWS
<p>I have a list of IPs and I want to filter out the IPs that come from AWS. Fortunately, AWS publishes a <a href="https://ip-ranges.amazonaws.com/ip-ranges.json" rel="nofollow">list</a> of their IPs. That list is in a JSON format, so I converted it to a <a href="https://json-csv.com/c/ru5L" rel="nofollow">CSV</a>. I then filtered my IP addresses using <code>my_ip = my_ip[~my_ip['col'].isin(amazon_ips['col'])]</code>.</p>

<p>Unfortunately, I think that the list is for ranges of IPs, rather than actually containing each IP that an AWS request could have come from. How can I correct for this?</p>

<p>The list you are getting contains IP Ranges using <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing" rel="nofollow">CIDR Notation</a>.</p>

<p>You could programmatically determine the individual IP addresses from a CIDR Block, if required: <a href="http://stackoverflow.com/questions/1942160/python-3-create-a-list-of-possible-ip-addresses-from-a-cidr-notation">Python 3: create a list of possible ip addresses from a CIDR notation</a></p>

python amazon-web-services pandas ip