AWS
EC2
Public IP
Cloud Computing
Networking

List public IP addresses of EC2 instances

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

In Amazon Web Services (AWS), Elastic Compute Cloud (EC2) is a core service that provides scalable computing capacity in the cloud. Each EC2 instance can be associated with public and private IP addresses, playing a crucial role in networking and communication. Public IPs allow instances to be accessible over the Internet. This article delves into how to list public IP addresses of EC2 instances using various AWS tools and interfaces.

Understanding EC2 Public IP Addresses

An EC2 instance can be assigned a public IP address based on its subnet configuration:

  • Public Subnet: Instances receive a public IP by default. This enables Internet traffic, governed by a route table with an Internet Gateway.
  • Private Subnet: Instances do not receive a public IP and usually require a NAT gateway for Internet-bound traffic.

Elastic IP Addresses

Elastic IP (EIP) is a static IPv4 address designed for dynamic cloud computing. It can be allocated to an AWS account and associated with EC2 instances. An EIP is retained in your account until explicitly released.

Methods to List Public IPs of EC2 Instances

There are several methods to list public IP addresses using AWS tools.

Using AWS Management Console

  1. Navigate to EC2 Dashboard: Go to the AWS Management Console and access the EC2 dashboard.
  2. Instances Section: Click on "Instances" to list all instances.
  3. Public IP Visibility: The "Public IP" column displays the public IPs of each instance.

Using AWS CLI

The AWS Command Line Interface (CLI) is a versatile tool for managing AWS services.

  • This command provides a table view of Instance IDs and their corresponding public IP addresses.
  • Based on AWS CLI versioning, ensure you use --query option properly for structured query requests.
  • Session Control: Set your AWS credentials and region to establish a connection to EC2.
  • Instance Iteration: Loop through instances to extract the public IP attribute.
  • Public IP Addresses are dynamic and can change if the instance is stopped and started.
  • Elastic IP Addresses remain constant unless manually reassigned or released.
  • While public IPs are typically costless, allocating more than one Elastic IP incurs charges.
  • Cost management is vital when using IPs extensively in enterprise settings.
  • Limiting access to instances via public IPs enhances security posture.
  • Use security groups and network ACLs to manage incoming traffic efficiently.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.