How do you get the private IP address of the eth1 network interface on an Amazon EC2 instance?

0

I've attached multiple elastic network interfaces to an Amazon EC2 instance, and I need get the private IP address of the eth1 network interface. What command(s) do I need to run to get it?

AWS
已提問 4 年前檢視次數 2850 次
1 個回答
0
已接受的答案

To get the private IP address of an Amazon EC2 instance, you can use either of the following describe-instances AWS CLI commands:

Important: Replace <instance-id> with your Amazon EC2 instance's ID. Replace <your-private-dns-name> with the private DNS name of the network interface.

aws ec2 describe-instances --instance-id <instance-id> --query 'Reservations[0].Instances[0].NetworkInterfaces[?Attachment.DeviceIndex==`1`].PrivateIpAddress'

-or-

aws ec2 describe-instances --filters Name=private-dns-name,Values=<your-private-dns-name> --query 'Reservations[0].Instances[0].NetworkInterfaces[?Attachment.DeviceIndex==`1`].PrivateIpAddress'
AWS
已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南