Unix Sockets 简明教程
Unix Socket - Network Host Names
就数字而言,主机名很难记住,因此它们被称为普通名称,例如 Takshila 或 Nalanda。我们编写软件应用程序来查找与给定名称对应的点分 IP 地址。
Host names in terms of numbers are difficult to remember and hence they are termed by ordinary names such as Takshila or Nalanda. We write software applications to find out the dotted IP address corresponding to a given name.
根据给定的字母数字主机名找出点分 IP 地址的过程称为 hostname resolution 。
The process of finding out dotted IP address based on the given alphanumeric host name is known as hostname resolution.
由驻留在高容量系统上的特殊软件执行主机名解析。这些系统称为域名系统 (DNS),它保留 IP 地址和相应的普通名称的映射。
A hostname resolution is done by special software residing on high-capacity systems. These systems are called Domain Name Systems (DNS), which keep the mapping of IP addresses and the corresponding ordinary names.
The /etc/hosts File
主机名与 IP 地址之间的对应关系保存在一个名为 hosts 的文件中。在大多数系统上,此文件位于 /etc 目录中。
The correspondence between host names and IP addresses is maintained in a file called hosts. On most of the systems, this file is found in /etc directory.
此文件中的条目看起来如下——
Entries in this file look like the following −
# This represents a comments in /etc/hosts file.
127.0.0.1 localhost
192.217.44.207 nalanda metro
153.110.31.18 netserve
153.110.31.19 mainserver centeral
153.110.31.20 samsonite
64.202.167.10 ns3.secureserver.net
64.202.167.97 ns4.secureserver.net
66.249.89.104 www.google.com
68.178.157.132 services.amrood.com
请注意,多个名称可能与给定的 IP 地址关联。转换 IP 地址到主机名和反之亦然时,将使用此文件。
Note that more than one name may be associated with a given IP address. This file is used while converting from IP address to host name and vice versa.
您无法访问此文件进行编辑,因此,如果您想将任何主机名与 IP 地址一起放入,那么您需要具有 root 权限。
You would not have access to edit this file, so if you want to put any host name along with IP address, then you would need to have root permission.