AWS Certified Advanced Networking – Specialty (ANS-C00) — Question 256
You need to find the public IP address of an instance that you're logged in to. What command would you use?
Answer options
- A. curl ftp://169.254.169.254/latest/meta-data/public-ipv4
- B. scp localhost/latest/meta-data/public-ipv4
- C. curl http://127.0.0.1/latest/meta-data/public-ipv4
- D. curl http://169.254.169.254/latest/meta-data/public-ipv4
Correct answer: D
Explanation
The correct command is option D because it properly accesses the instance metadata service over HTTP to retrieve the public IPv4 address. Option A incorrectly uses the FTP protocol, which is not supported for this metadata endpoint. Option B incorrectly utilizes the SCP command, which is not meant for accessing metadata, and option C uses the localhost address, which will not provide the instance's public IP address.