logo

该视频仅会员有权观看

立即开通课程「Node.js基础」权限。

¥
199
/ 年

理解主机名配置文件<hosts>

  • The hostname localhost can access services running on a local computer because it points to a special IP address representing the local device, which is 127.0.0.1 for IPv4.
  • For IPv6, the corresponding address is ::1.
  • One can use the ping command to test the localhost hostname and find it resolves to 127.0.0.1.
  • The resolution of the localhost hostname to its corresponding IP address is configured in a file called hosts.
  • On macOS, the hosts file is located at /etc/hosts, and on Windows, it can be found in C:\Windows\System32\drivers\etc.
  • The hosts file includes records linking 127.0.0.1 and ::1 to localhost, indicating both IPv4 and IPv6 addresses for the local host.
  • Computers first check the hosts file for hostname records before querying DNS.
  • Editing the hosts file only affects the current computer and not other devices.