/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类似的两行,其余的视情况而定
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)