我正在尝试通过SSH从10.04系统连接到12.04系统。奇怪的是,这些规则resolv.conf
似乎只能选择性地生效,这让我感到困惑。观察:
[2] user@mach:~$ ssh pangolin
ssh: Could not resolve hostname pangolin: Name or service not known
[2] user@mach:~$ host pangolin
pangolin.subdomain.domain.tld has address 172.16.7.12
subdomain.domain.tld
是在search
排队/etc/resolv.conf
,并使用host
该名称是否正确找遍给出的规则。但是,使用SSH客户端,ssh
我会收到上面再现的错误。怎么会这样?我一直给人的印象是,名称解析规则resolv.conf
适用于system-global。
注意:/etc/hosts
完全不声明名称pangolin
。该软件包openssh-server
已在目标计算机上配置。问题仅在于为什么这两个程序之间的名称解析不一致。
另一个注意事项:输入完全限定的域名(即)时,该命令运行良好pangolin.subdomain.domain.tld
。
同时,我重新启动了客户端计算机(10.04),问题仍然存在。没有安装DNS缓存守护程序,因此我认为无论如何都不应该成为问题。
评论中要求的信息:
$ grep host /etc/nsswitch.conf
hosts: files dns
/etc/resolv.conf
,我一致地转换了域名:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 172.16.1.1
nameserver 172.16.1.5
search subdomain.domain1.com domain1.com domain2 domain3.com domain2.ccTLD domain3.net dev.domain1.com sdk.dev.domain1.com
...以及完整内容/etc/nsswitch.conf
:
$ cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
...和/etc/network/interfaces
,这是resolv.conf
12.04中的来源:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 172.16.1.234
netmask 255.255.0.0
gateway 172.16.255.254
dns-nameservers 172.16.1.1 172.16.1.5
dns-search domain1.com. domain2. domain3.com. domain2.ccTLD. domain3.net. dev.domain1.com. sdk.dev.domain1.com. subdomain.domain1.com.
dns-domain subdomain.domain1.com.
注意:域名的转换是通过进行的sed
,因此在各种复制文件之间保持一致。
没有~/.ssh/config
,但是这里是全局的(/etc/ssh/ssh_config
),为简洁起见缩小了:
$ grep -v '^#' /etc/ssh/ssh_config |grep -v '^[[:space:]]*$'
Host *
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
$ mtr pangolin
Name or service not known: Success
mtr pangolin
吗?
/etc/resolv.conf
此命令的输出grep host /etc/nsswitch.conf
吗?