简体   繁体   English

AWS Public IP在运行实例中

[英]Aws public ip in runing instance

When i do ifconfig in my EC2 instance I get private IP. 当我在EC2实例中执行ifconfig时 ,我获得了专用IP。 But adding to sites-available in my apache I need public ip. 但是要添加到我的Apache中可用的站点 ,我需要公共IP。

Is there any way i can get my public IP in my running instance. 有什么办法可以在运行实例中获取我的公共IP。

There is a "magic IP" on amazon EC2 instaces which you can curl for metadata about your instance. 亚马逊EC2实例上有一个“魔术IP”,您可以卷曲该实例的元数据。

To get the public IP of a current instance you can do: 要获取当前实例的公共IP,您可以执行以下操作:

curl http://169.254.169.254/latest/meta-data/public-ipv4

You can read the full documentation here . 您可以在此处阅读完整的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM