Similar to AWS, Google Compute Engine also has a Metadata server. You can get the external IP address by this command:
Note that you need to include the additional header, otherwise your request will be rejected for security reasons.
curl "http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip" -H "X-Google-Metadata-Request: True"
Note that you need to include the additional header, otherwise your request will be rejected for security reasons.
No comments:
Post a Comment