小白的服务器是个双机,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类似的两行,其余的视情况而定

GitHub 加速计划 / li / linux-dash
10
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:1 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐