Amazon Web Services (AWS) - List Network Interfaces using the AWS CLI

by
Jeremy Canfield |
Updated: March 23 2024
| Amazon Web Services (AWS) articles
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
The aws ec2 describe-network-interfaces command can be used to list each Network Interface in each of your Virtual Private Clouds.
aws ec2 describe-network-interfaces
And here is an example of how to limit the output using the --query option.
aws ec2 describe-network-interfaces --query 'NetworkInterfaces[?VpcId==`vpc-123456789abcdefg`]'
And here is an example of how to limit the output using the --filters option.
aws ec2 describe-network-interfaces --filters Name=interface-type,Values=network_load_balancer
Something like this should be returned.
{
"NetworkInterfaces": [
{
"Association": {
"AllocationId": "eipalloc-0a5c72c343bc546b0",
"AssociationId": "eipassoc-0b12eaaacc74f9e24",
"IpOwnerId": "123456789012",
"PublicDnsName": "ec2-107-22-51-98.compute-1.amazonaws.com",
"PublicIp": "107.22.51.98"
},
"Attachment": {
"AttachTime": "2022-11-06T09:23:52+00:00",
"AttachmentId": "eni-attach-07beca2ecabe2fdd2",
"DeleteOnTermination": true,
"DeviceIndex": 0,
"NetworkCardIndex": 0,
"InstanceId": "i-09e2e375cf14807b2",
"InstanceOwnerId": "123456789012",
"Status": "attached"
},
"AvailabilityZone": "us-east-1c",
"Description": "",
"Groups": [
{
"GroupName": "default",
"GroupId": "sg-0c3296b3cd153fdc1"
}
],
"InterfaceType": "interface",
"Ipv6Addresses": [],
"MacAddress": "0a:c8:79:d2:a0:61",
"NetworkInterfaceId": "eni-004a4335b85583ae2",
"OwnerId": "123456789012",
"PrivateDnsName": "ip-172-31-19-227.ec2.internal",
"PrivateIpAddress": "172.31.19.227",
"PrivateIpAddresses": [
{
"Association": {
"AllocationId": "eipalloc-0a5c72c343bc546b0",
"AssociationId": "eipassoc-0b12eaaacc74f9e24",
"IpOwnerId": "123456789012",
"PublicDnsName": "ec2-107-22-51-98.compute-1.amazonaws.com",
"PublicIp": "107.22.51.98"
},
"Primary": true,
"PrivateDnsName": "ip-172-31-19-227.ec2.internal",
"PrivateIpAddress": "172.31.19.227"
}
],
"RequesterManaged": false,
"SourceDestCheck": true,
"Status": "in-use",
"SubnetId": "subnet-03c64e403dc5bf18f",
"TagSet": [],
"VpcId": "vpc-014d2fcfa335d3c01"
}
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at