Question re: the public IP assigned on new instance

Newbie Questions: Please be kind!

Not talking about Elastic IPs which are static IPs.
This question is about those public IPs you can get when setting up a new instance, in order to ssh into the instance. The ones that change each time you stop & start the instance.

  1. Is there a cost associated with this IP?
  2. Is there a limit to the number of such IPs you can obtain? Say you start 20 instances, each with a public IP to ssh into it? Or hundreds?
  3. If you set up such public access at time of instance creation, but then set up a firewall within using ports such that you can ssh through port forwarding and no longer need these public IPs, can they be given up?

Edit: I should add - each of these servers is similar but serves a different need, so needs some level of customization, including on the local firewall on the server. So it needs access initially. While its great to have direct access from the internet, it seems that there would be a limit to the number of IPs available and also some cost associated

Short answer only because you can get the answer with just use Google:

  • Nope
  • Nope, but you are limited to the numbers of the instance which you can launch (soft limit)
  • Mission Impossible. That public IP address tied with the primary ENI which can’t be removed unless you terminate the instance.

Thanks! I did search on Google but I was mostly getting links to Elastic IPs.

Just wondering how many IPs AWS has available, must be a huge number if it can assign 1 to each instance that needs it for direct ssh.

Yep, it hard to find those infos because AWS didn’t mentioned directly in their docs! But when you be more familiar with AWS you will know how and where to find such those of info!

Still wondering how many IPv4 AWS owned? - the answer is they have ~ 53 Million IPv4 addresses (and maybe expand more) which cost about over $2.5 billion Biden dollars. :slight_smile:

This is the list of AWS IP address ranges : https://ip-ranges.amazonaws.com/ip-ranges.json

While it is true that they will need lots of IP addresses for each EC2 Instance it is not really necessary in real world scenario. Most Production servers are usually behind Bastion hosts. You SSH to these and then use the Private IPs of the servers. Also the servers need to be in “running” state in order to retain the Public IP that AWS assigns. If you stop and start the server they are assigned a new Public IP again.

You can see all of AWS’ IP ranges. This doc describes how to get that list: https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

and maybe expand more

The other day I found this interesting article: https://toonk.io/aws-and-their-billions-in-ipv4-addresses/index.html

They analyze not only what the API tells us, but also a lot of acquisitions, put them together, and counts over 100M IPs now!

Actually I thought you can put an EC2 instance in a VPC that has no public interface and then it won’t get provisioned a public IP. Same as how you can enable or disable ipv6 provisioning.

Wow….thank you for the info.

Thanks! Yes I forgot these IPs are for running instances.

Also re: Bastion hosts - I will review that for our use, thanks on that front too!