【问题标题】:Not clear why my /etc/hosts look like this不清楚为什么我的 /etc/hosts 看起来像这样
【发布时间】:2013-12-01 00:23:33
【问题描述】:

我有点困惑,我的主机文件看起来像:

   > 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1         localhost localhost.localdomain
   > localhost6 localhost6.localdomain6
   > 127.0.0.1 autoreply.panel.mywebsite.com
   > 127.0.0.1 myhostname 
   > 127.0.0.1 panel.mywebsite.com

为什么不显示机器IP地址??即便如此,该网站仍在运行,并且可以从 Web 访问该网站。

谁能解释一下??谢谢你

【问题讨论】:

    标签: centos vps


    【解决方案1】:

    将 /etc/hosts 视为 dns 系统覆盖。您可以在此文件中按 IP 地址指定主机名。

    例如,您可以执行以下操作:

    echo "127.0.0.1 google.com" >> /etc/hosts
    

    然后继续 ping google.com:

    [jclark@jclark530 ~]$ ping -c1 google.com
    PING google.com (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.028 ms
    

    您连接的服务器 IP 地址将通过运行 /sbin/ifconfig 显示

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-21
      • 1970-01-01
      • 2011-04-29
      • 2016-04-07
      • 1970-01-01
      • 2017-06-17
      • 1970-01-01
      相关资源
      最近更新 更多