为什么此主机文件条目仅适用于浏览器和主机名?

Why does this hosts file entry only work with a browser and the host name?

我工作站的 C:\Windows\System32\drivers\etc\hosts 文件包含以下(假设的)IP 地址映射:

111.222.33.444         sub.domain.tld

在 Firefox 中,我可以成功浏览到 sub.domain.tld 主机名。因为我可以浏览到主机名...

  1. 为什么我不能直接浏览到111.222.33.444 IP地址?
  2. 为什么我不能 ping 111.222.33.444sub.domain.tld

显然我不了解主机文件的作用。

Why can I not browse directly to the 111.222.33.444 IP address?

可能是服务器的默认虚拟主机与 sub.domain.tld 不同。该默认虚拟主机可能被设置为拒绝您的请求。

Why can I ping neither 111.222.33.444 nor sub.domain.tld?

ping sub.domain.tld 将 ping 111.222.33.444,但不需要服务器响应 ping。它(以及您)可能会被防火墙从 ICMP 流量中分离出来。