Temporary failure in name resolution
虚拟机17导入旧镜像,ping baidu.com
报错:Temporary failure in name resolution,但是ping ip,比如ping 8.8.8.8
却正常。
修改/etc/resolv.conf,添加nameserver是不起作用的。
ubuntu22
尝试用resolvectl
修改接口的dns服务器地址
这是出现Temporary failure in name resolution的状态:
$ sudo resolvectl status
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (ens33)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.145.2
DNS Servers: 192.168.145.2
DNS Domain: localdomain
Link 3 (docker0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
修改为1.1.1.1
sudo resolvectl dns ens33 1.1.1.1
这是ping一下,是可以ping通的,但是延迟很高。(别急着去操作,看完后面!!!)
ping baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
64 bytes from 39.156.66.10: icmp_seq=1 ttl=128 time=48.3 ms
64 bytes from 39.156.66.10: icmp_seq=2 ttl=128 time=42.4 ms
64 bytes from 39.156.66.10 (39.156.66.10): icmp_seq=3 ttl=128 time=42.8 ms
64 bytes from 39.156.66.10: icmp_seq=4 ttl=128 time=42.3 ms
64 bytes from 39.156.66.10: icmp_seq=5 ttl=128 time=41.9 ms
^C64 bytes from 39.156.66.10: icmp_seq=6 ttl=128 time=43.7 ms
--- baidu.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 45583ms
rtt min/avg/max/mdev = 41.931/43.559/48.250/2.171 ms
换成其他dns服务器又不行,换回1.1.1.1也不行。
下面是NAT-网络拓扑结构图,对应我的虚拟机环境,虚拟网卡地址是192.168.145.1,虚拟交换机是192.168.145.2
用nmap扫描192.168.145.2(虚拟交换机)发现53端口是开的,也就是默认就应该由这个地址来充当域名解析。
最后的操作
- 升级虚拟机。由于镜像是用的之前16版本的,现在的是17,所以点了升级虚拟机。(注意升级后的虚拟机不会向下兼容)
- 虚拟网络编辑器,NAT模式,还原默认设置。
这两步我也不清楚是哪个起了作用。。。。
当前配置
Ubuntu:
$sudo resolvectl status
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (ens33)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.239.2
DNS Servers: 192.168.239.2
DNS Domain: localdomain
Link 3 (docker0)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
/etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically 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 127.0.0.53
options edns0 trust-ad
search localdomain
/etc/hosts
127.0.0.1 localhost
127.0.1.1 zsc
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
kali:
kali上没有resolvectl,需要手动安装——
sudo apt install systemd-resolved
也可以使用其他命令查看相关信息:
nmcli dev show
ip addr show
ip route show
resolvectl status:
$ sudo resolvectl status
Global
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (eth0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 mDNS/IPv4 mDNS/IPv6
Protocols: +DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 192.168.239.2
DNS Domain: localdomain
/etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically 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 127.0.0.53
options edns0 trust-ad
search localdomain
/etc/hosts
127.0.0.1 localhost 127.0.1.1 kali ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters