VirtualBox 虚拟机无法通过主机名相互 ping 通

VirtualBox 虚拟机无法通过主机名相互 ping 通

我对 VirtualBox 还不熟悉。我有 Windows 10 主机操作系统,并在其上安装了 Vagrant 2x VMs Ubuntu 20.04,带有仅主机适配器以及 Vagrant 添加的默认 NAT 适配器。虽然我可以使用 IP 相互 ping 虚拟机,但通过主机名在它们之间 ping 却不行!

这是我的 DNS 配置:

vagrant@ubuntu-k8s-master:~$ resolvectl
.....Link 3 (eth1)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 2 (eth0)
      Current Scopes: DNS
DefaultRoute setting: yes
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 10.0.2.3
          DNS Domain: home

这是我的 IP 配置:

vagrant@ubuntu-k8s-master:~$ ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:a2:6b:fd brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 84709sec preferred_lft 84709sec
    inet6 fe80::a00:27ff:fea2:6bfd/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:ec:45:5e brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.10/24 brd 10.0.0.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:feec:455e/64 scope link
       valid_lft forever preferred_lft forever
...

其中 eth0 是 NAT,而 eth1 是仅主机适配器。

通过主机名进行 nslookup 也失败:

vagrant@ubuntu-k8s-master:~$ nslookup ubuntu-k8s-worker01
;; Got SERVFAIL reply from 127.0.0.53, trying next server
Server:         127.0.0.53
Address:        127.0.0.53#53

** server can't find ubuntu-k8s-worker01: SERVFAIL

vagrant@ubuntu-k8s-master:~$ nslookup ubuntu-k8s-worker01.local
;; Got SERVFAIL reply from 127.0.0.53, trying next server
Server:         127.0.0.53
Address:        127.0.0.53#53

** server can't find ubuntu-k8s-worker01.local: SERVFAIL

而 nslookup 适用于公共名称。

我想我可能需要添加自己的 DNS,以便虚拟机能够通过主机名进行通信?

谢谢

相关内容