EC2 IP Addresses

Types of IP Addresses in EC2

TypeScopeStatic?Charges?Use Case
Private IPInternal✔ Yes❌ NoInternal VPC communication
Public IPInternet❌ No❌ NoQuick internet access
Elastic IP (EIP)Internet✔ Yes⚠️ YesStatic access, failover setups
IPv6Internet✔ Yes❌ NoGlobal routing, IPv6 access

EC2 IP Types

How to Connect

ssh -i mypem.pem aws-user@hostname

Warning

SG must have ssh inbound Rule

How to Check Public IP? ( AutoAssigned or EIP )

[ec2-user@ip-172-31-7-13 ~]$ curl ipinfo.io
{
  "ip": "3.7.70.216",
  "hostname": "ec2-3-7-70-216.ap-south-1.compute.amazonaws.com",
  "city": "Mumbai",
  "region": "Maharashtra",
  "country": "IN",
  "loc": "19.0728,72.8826",
  "org": "AS16509 Amazon.com, Inc.",
  "postal": "400017",
  "timezone": "Asia/Kolkata",
  "readme": "https://ipinfo.io/missingauth"
}

How to Check Private IP?

ifconfig

or

[ec2-user@ip-172-31-7-13 ~]$ hostname -I
172.31.7.13