How many IP addresses does AWS own?
February 26 2020
| tech |
I use AWS for personal and work projects, and I was curious tonight as I am spinning up VMs left and right, and allocating a new IP address to each of them (via ENIs): just how many IP addresses does AWS own?
So, like most people, I googled it (thinking DDG wouldn't have as solid an answer), and wouldn't you know it, I was right that Google did have an answer!
Okay, so AWS has 5 IP addresses. Terrific.
Next, we just need to do a bit of bash parsing to get the IP network prefix, and then subtract that value from 32 to get the power of 2 exponent, which we can use to calculate the number of unique IP addresses matching that IP prefix.
$ grep -o "/.*" ~/Downloads/ip-ranges.json | cut -d '/' -f 2 | cut -d '"' -f 1 > ~/vals.txt $ while read line; do echo "32 - $line" | bc; done < ~/vals.txt > ~/exp.txt $ head ~/exp.txt 8 19 8 8 8 17 16 17 9 8
$ scala scala> val lines = io.Source.fromFile("/Users/fitz/exp.txt").getLines.toList scala> lines.map(x => math.pow(2, x.toLong).toLong).sum res0: Long = 98293797
So, there you have it! Amazon, or AWS at least, owns 98,293,797 IP addresses as of February 26th 2020. At first I thought that seemed kind of low, given that every VM that their customers spin up can receive a public IPv4 address if the customer wants. But, I guess even if Netflix spins up a million VMs or Fargate containers with ENIs, that would still only exhaust 1% of their IP address space. I'm not sure---maybe that is low? IPv6 to the rescue.