/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类似的两行,其余的视情况而定

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值