Interview Prep/Networking/Command-Line Tools & Diagnostics

How do you check the public IP of a host and the metadata that explains it?

BeginnerConceptCommand-Line Tools & Diagnostics
Answer
curl -s https://checkip.amazonaws.com
curl -s -H "X-aws-ec2-metadata-token: $(curl -s -X PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds: 60')" http://169.254.169.254/latest/meta-data/public-ipv4

The first shows the egress address the world sees (a NAT gateway's EIP for private instances), the second the instance's own assigned public IP.

All Networking questions Roadmap: Networking for DevOps

More on Command-Line Tools & Diagnostics