AWS EC2:如何从Ubuntu实例内部了解公共IP [英] aws ec2: how to know public ip from inside ubuntu instance
问题描述
我创建了一个amazon-web-services实例,并使用了Ubuntu 14.04 amazon机器映像。
I created a amazon-web-services instance and used the Ubuntu 14.04 amazon machine image.
现在我可以使用该机器并使用Shell来运行不同的了命令。
now I can ssh into that machine and use the shell to run different commands.
我现在的问题是,如何从ssh会话内部从该计算机中找到公共IP?
my question is now, how I can find out the public IP from that machine from inside that ssh-session?
我尝试使用
netstat
和
ifconfig
但找不到
有没有人可以告诉我如何找到我曾经通过SSH进入机器的IP?
Is there somebody who can tell me how to find out, the ip I used to ssh into the machine?
预先感谢!
推荐答案
这个问题已经问了很多次了。您需要的是实例元数据和用户数据 。
This question has been ask many time. What you need is Instance Metadata and User Data.
只需执行此操作并参考提到的文档,您就会获得公共ip地址:
Just do this and refer to the mentioned documentation, you get the public ip address :
curl http://169.254.169.254/latest/meta-data/public-ipv4
这篇关于AWS EC2:如何从Ubuntu实例内部了解公共IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!