01 / 03

Discuss Private and Public IP in AWS EC2

Difficulty: 5/10
IP addressing, VPC networking, NAT

Public vs. Private IP Addressing

In AWS EC2, instances utilize two types of IP addresses to facilitate communication. Private IP addresses are primary for internal communication within your VPC, while Public IP addresses allow instances to communicate with the internet.

Key Differences
  1. 1

    Private IP: Assigned from the VPC subnet range; primary address for communication between instances in the same or peered VPCs.

  2. 2

    Public IP: Maps to the instance's private IP via NAT; used for inbound/outbound communication with the internet.

  3. 3

    Persistence: Public IPs assigned at launch are released when the instance is stopped; Private IPs persist for the lifetime of the network interface.

Scenario Questions

0-2 years experience

  1. 1You need to launch an EC2 instance that should be reachable from the internet for a web app. How would you assign a public IP, and what steps ensure it stays reachable after a stop/start?
  2. 2If you launch an EC2 instance inside a default VPC without specifying any IP settings, what private IP will it get and can you SSH into it from your laptop directly? Explain why.

2-5 years experience

  1. 1Your microservice runs in a private subnet and needs to call an external API. The team added a NAT gateway but the calls still time out. Walk me through how you would debug the IP routing and what could be misconfigured.
  2. 2During a blue‑green deployment you notice that the new instances can’t be accessed via the load balancer, while the old ones work. The only difference is that the new instances were launched without a public IP. Explain the impact and how you would fix it without recreating the whole environment.

5-8 years experience

  1. 1We are designing a multi‑region data pipeline where EC2 workers in each region need to pull data from a central S3 bucket via VPC endpoints. Discuss how you would decide between using public IPs with an internet gateway versus private IPs with VPC endpoints, considering cost, security, and latency.
  2. 2Your company wants to expose a set of internal admin tools to a handful of external contractors. You need to decide whether to give those EC2 instances public IPs, use a bastion host, or set up a VPN. Compare the trade‑offs and outline the architecture you’d choose.

8+ years experience

  1. 1As part of a migration from on‑premises to AWS, you must move a fleet of servers that currently rely on static public IPs for partner integrations. Describe a strategy to preserve those IP addresses at scale, covering Elastic IP allocation, NAT, and DNS considerations.
  2. 2You are leading a cross‑team effort to standardize networking across dozens of micro‑services. How would you create a policy that enforces the correct use of private vs. public IPs for EC2 instances, and what tooling or automation would you put in place to enforce it over time?

Follow-up Questions

  • What security concerns arise when you assign a public IP to an instance?
  • How does an Elastic IP differ from a public IP assigned at launch?
  • Can an instance have both a private and a public IP simultaneously, and how does traffic flow between them?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.