/etc/hosts主机名映射

小白的服务器是个双机,linux01和linux02,两者之间有信任关系,在linux101上面以root用户可以通过“ssh linux102”跳到备机上去的,但是今天,跳的不顺利,出现了如下报错:

linux101:~ # ssh linux102
ssh: Could not resolve hostname linux101: Name or service not known


小白找了很多原因,无果,最后经由师傅提醒,查看了一下/etc/hosts文件:

 

#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1       localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts
192.168.100.101 linux101-heart
#10.137.73.102 linux102
127.0.0.1 linux101

 

这里10.137.73.102 linux102被注释了,致使引用 linux102时,无法自动解析成10.137.73.102,取消注释后,重新执行命令“ssh linux102”

linux101:~ # ssh linux102
Authorized users only. All activity may be monitored and reported.
Last login: Wed Nov 13 10:53:39 2013 from 10.137.226.114
Authorized users only. All activity may be monitored and reported.

总结: 1. /etc/hosts是IP和主机名解析的文件

            2. 在/etc/hosts中一般都会有 127.0.0.1 localhost   和 127.0.0.1  linux101类似的两行,其余的视情况而定

你可能感兴趣的:(/etc/hosts主机名映射)