Interview Prep/Networking/Cloud networking: VPC, firewalls, NAT, VPN and proxies

A new EC2 instance in a "public" subnet can't be reached over SSH from the internet; the SG allows port 22 from your IP.

BeginnerTroubleshootingCloud networking: VPC, firewalls, NAT, VPN and proxies
Answer

Likely causes → The instance has no public IPv4 (subnet doesn't auto-assign and none was requested), the subnet's route table has no 0.0.0.0/0 → igw-xxxx, a NACL blocks it, or your IP changed.

Diagnose →

aws ec2 describe-instances --instance-ids <id> \
  --query 'Reservations[0].Instances[0].[PublicIpAddress,SubnetId]'
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=<subnet-id>
curl -s https://checkip.amazonaws.com

Use VPC Reachability Analyzer from the IGW to the ENI on port 22 for a definitive answer.

Fix → Attach an Elastic IP or enable auto-assign public IP, add the IGW route, fix the NACL, update the SG with your current IP.

Prevent → Prefer SSM Session Manager over public SSH entirely; no inbound port, no public IP needed.

All Networking questions Roadmap: Networking for DevOps

More on Cloud networking: VPC, firewalls, NAT, VPN and proxies