AWS EC2:如何从Ubuntu实例内部了解公共IP [英] aws ec2: how to know public ip from inside ubuntu instance

查看:144
本文介绍了AWS EC2:如何从Ubuntu实例内部了解公共IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆