我无法通过主机名 ping 通 - Ubuntu 服务器

我无法通过主机名 ping 通 - Ubuntu 服务器

我有一台 ubuntu 服务器。当我从网络上的计算机 ping ubuntu 服务器的 IP 时,一切正常并有响应。如果通过主机名 ping - “Ping 请求找不到主机 ubuntu-vm.spkso.local。请检查名称并重试。”

/etc/netplan/50-cloud-init.yaml

network:   version: 2   ethernets:
ens160:
  addresses: [192.168.3.3/24]
  gateway4: 192.168.3.6
  nameservers:
    addresses: [192.168.3.9, 192.168.3.20]

/etc/主机名

Ubuntu 虚拟机

/etc/resolv.conf

nameserver 127.0.0.53
nameserver 192.168.9
nameserver 192.168.20
options edns0 trust-ad

答案1

根据你留下的评论,我大胆猜测你的/etc/hosts文件在主机上是不完整的。您可能希望将其设置为如下形式:

127.0.0.1       localhost
192.168.3.3     ubuntu-vm.spkso.local ubuntu-vm

# 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

如果您知道虚拟机的 IPv6 地址,请将其放在文件末尾。设置此文件后,您应该能够ping ubuntu-vm并且ping ubuntu-vm-spkso.local名称将解析为正确的本地地址。

相关内容