【问题标题】:What is the difference between the IP address needed for ssh, and the IP address that is displayed once inside the serverssh所需的IP地址和服务器内部显示一次的IP地址有什么区别
【发布时间】:2015-07-28 20:17:03
【问题描述】:

当我ssh 进入我的服务器时,我发出以下命令:

ssh <username>@<ip-of-server>

然后,当我进入时,我会看到以下提示:

<username>@ip-<different-ip-address>:

当我在服务器中尝试echo $PS1 时,我看到以下内容:

\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$,它告诉我主机必须不同。为什么这些不一样:ip 和 host?

我问的原因是,我可以通过 ssh-ing 访问就好了,但我无法 ping 它:

ping <ip-of-server> ... 导致 100% 的损失。

所以,我想也许我应该 ping 另一个 ip,但是:

ping ip-<different-ip-address> ... 也会导致 100% 的损失。

怎么可能ping不通,但我还能登录?

【问题讨论】:

  • 可能<ip-of-server> 是公网IP 而<different-ip-address> 是私网
  • 怎么测试呢?
  • 只检查<different-ip-address> 范围,如果是私人应该b:From 10.0.0.0 to 10.255.255.255. From 172.16.0.0 to 172.31.255.255. From 192.168.0.0 to 192.168.255.255

标签: php amazon-web-services ip ping host


【解决方案1】:

私有 IP 位于 AWS 内部,即 10.x.x.x

你也可以通过调用来检查

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

在从元数据服务器获取该信息的实例中。

公共 IP(如果已分配)是外部 IP。您可以从元数据服务器获得相同的信息。试试:

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

如果你的shell提示有问题,可以在查询公网IP后设置提示。

【讨论】:

    【解决方案2】:

    ip-of-server 可能是服务器的公共 ip。 different-ip-address 可能是服务器的私有 ip。

    ping 不会从外部通过,除非您通过您为实例设置的安全组启用 ICMP 流量。

    可以登录,因为用于 SSH 的端口在安全组中是打开的 (TCP 22),而 ICMP 未打开 (ICMP)。

    【讨论】:

      猜你喜欢
      • 2011-07-29
      • 2022-01-24
      • 2011-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-06
      • 2013-04-24
      • 1970-01-01
      相关资源
      最近更新 更多