Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
Retrieving the private IP addresses in a subnet in AWS

Is there an easy way to have all the private IP assigned in a particular subnet with the AWS command line?

I want to give in as my input the subnet ID, ie. subnet-0ca0b01xxxxxxxxxx and the output should the list of all the private IPs assigned in the subnet. Thanks.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use the command below:

aws ec2 describe-instances --filters "Name=subnet-id,Values=**YourSubnetID**" --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text
over 4 years ago · Santiago Trujillo Report

0

The previous solution only returns the private IPs for your EC2 instances, but what about your RDS/ElastiCache instances or any other AWS resource that uses a private IP? You actually need to use the describe-network-interfaces command.

This will return all the private IP addresses for a single or multiple subnet-ids:

aws ec2 describe-network-interfaces --filters Name=subnet-id,Values=subnet_id_1,subnet_id_2 --query 'NetworkInterfaces[*].PrivateIpAddress'

But the previous command it's not going to work for all cases either. For example, I'm running multiple EKS clusters at AWS, the VPC CNI plugin for Kubernetes can allocate multiple private IPs for a single Elastic Network Interface In such scenarios this is what you need to use, it's slightly different:

aws ec2 describe-network-interfaces --filters Name=subnet-id,Values=subnet_id_1,subnet_id_2 --query 'NetworkInterfaces[*].PrivateIpAddresses[*].PrivateIpAddress'
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!