Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda