这个周末我更新了内核,现在我使用的是5.3.1。
christopher@HAL4:~$ uname -r
5.3.1-050301-generic我需要登录到服务器,但不能再用主机名登录了。例如,我有一个服务器"web4“,它的本地IP是192.168.64.140。如果我去挖:
christopher@HAL4:~$ dig web4
; <<>> DiG 9.11.3-1ubuntu1.9-Ubuntu <<>> web4
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1580
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;web4. IN A
;; ANSWER SECTION:
web4. 0 IN A 192.168.64.140
;; Query time: 0 msec
;; SERVER: 192.168.3.222#53(192.168.3.222) <---- Correct!
;; WHEN: Mon Sep 30 09:50:31 CDT 2019
;; MSG SIZE rcvd: 49nslookup也是一样的:
christopher@HAL4:~$ nslookup web4
Server: 192.168.3.222
Address: 192.168.3.222#53
Name: web4
Address: 192.168.64.140但是,ping或ssh都不工作('login‘是一个使用我的键的bash脚本):
christopher@HAL4:~$ ping web4
ping: web4: Name or service not known
christopher@HAL4:~$ login web4
ssh: Could not resolve hostname web4: Name or service not known 我的/etc/是:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 192.168.3.222
nameserver 192.168.70.80它是指向/run/systemd//的符号链接。
这是my /etc/netplan/01-netplan all.yaml文件:
christopher@HAL4:~$ cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp4s0:
dhcp4: no
addresses: [192.168.2.47/19]
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.3.222,192.168.70.80]我的DNS怎么了?!
发布于 2019-09-30 15:09:11
检查/etc/nsswitch.conf
查找启动hosts的行,并确保其上有dns。
hosts: files dnsUpdate -正如您在评论中所说的,您的nsswitch.conf有:
hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns myhostname这意味着主机解析将首先查找/etc/host,然后使用mdns4_minimal,这意味着您正在使用avahi守护进程服务,也许这不是在运行吗?如果它不能使用mdns解析,主机解析就会失败--这通常是出于设计,以确保分辨率一定要使用avahi,这意味着系统的解析器也可能被配置.[!UNAVAILBLE=return]意味着系统解析将始终用于up,但如果不使用,则继续使用nss-dns .因此,确定如何将名称解析为地址,如果不使用mdns,则可以删除mdns4_minimal [NOTFOUND=return],这样对您可能更好:
hosts: files resolve [!UNAVAIL=return] dns myhostname甚至:
hosts: files dns myhostname发布于 2019-09-30 15:47:58
ping通过系统解析,同时使用dig直接发送请求。这就是为什么有不同的结果。
至于如何解决这个问题--不对主机使用单独的区域并不是最好的(甚至是好的)实践。比如说,Ubuntu18.04附带的mDNS (Multicast )服务期望.local成为默认区域,除非明确指定它。
当然,如果系统中不需要mDNS,那么只需相应地调整/etc/nsswitch.conf即可。但是通常(阅读“遵循最佳实践”),您应该为您的LAN有单独的DNS区域,您可以在默认情况下尝试设置它,即使您省略了它的名称。
https://serverfault.com/questions/986231
复制相似问题