一台虚拟机中找不到 DNS,而另一台配置几乎相似的虚拟机却能正常工作

一台虚拟机中找不到 DNS,而另一台配置几乎相似的虚拟机却能正常工作

我有一个 Virtualbox 服务器,上面运行着多个 Virtualbox 客户端。更换 ISP 后,这个功能不再起作用了。我向在线帮助寻求帮助,结果得到了很好的帮助在 Linux 上连接两个子网但没有解决。借助离线帮助(不幸的是我无法重现),解决了大部分问题。但不是全部。

虚拟机 Vbox1a (Ubuntu) 运行良好:外部 DNS 工作正常:

bernard@vbox1a:/etc/network$ ping www.google.com
PING www.google.com (64.233.166.147) 56(84) bytes of data.
64 bytes from wm-in-f147.1e100.net (64.233.166.147): icmp_req=1 ttl=63    time=15.3 ms

以及内部 DNS:

bernard@vbox1a:/etc/network$ ping www.mysite.com
PING www.mysite.com (192.168.1.73) 56(84) bytes of data.
64 bytes from 192.168.1.73: icmp_req=1 ttl=64 time=1.68 ms
^C64 bytes from 192.168.1.73: icmp_req=2 ttl=64 time=0.611 ms

虚拟机 Vbox1a 具有以下配置:

bernard@vbox1a:/etc$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:f1:68:9e  
          inet addr:192.168.1.90  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef1:689e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1263592 errors:0 dropped:344 overruns:0 frame:0
          TX packets:180911 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:244455084 (244.4 MB)  TX bytes:12573980 (12.5 MB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:79:02:34  
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe79:234/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:446519 errors:0 dropped:0 overruns:0 frame:0
          TX packets:303468 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:196576684 (196.5 MB)  TX bytes:28701402 (28.7 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:257512 errors:0 dropped:0 overruns:0 frame:0
          TX packets:257512 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:20038093 (20.0 MB)  TX bytes:20038093 (20.0 MB)

和路由表:

bernard@vbox1a:/etc/network$ ip route show
default via 10.0.3.2 dev eth1  proto static 
10.0.3.0/24 dev eth1  proto kernel  scope link  src 10.0.3.15  metric 1 
169.254.0.0/16 dev eth0  scope link  metric 1000 
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.90 

和接口:

bernard@vbox1a:/etc/network$ cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
dns-nameservers 192.168.1.70 192.168.1.1

auto eth0 
iface eth0 inet static
address 192.168.1.90
netmask 255.255.255.0 
gateway 192.168.1.1

到目前为止一切顺利。所以我唯一要做的就是,将这些设置(稍作调整)复制到另一个 Ubuntu 虚拟机。但这行不通。

但是 Vbox11 (Ubuntu) 不起作用:DNS 不起作用:

bernard@vbox11:/etc/network$ ping www.google.com
ping: unknown host www.google.com

但 ping 到 IP 地址 (www.google.com) 时却成功了:

bernard@vbox11:/etc/network$ ping 64.233.166.147
PING 64.233.166.147 (64.233.166.147) 56(84) bytes of data.
64 bytes from 64.233.166.147: icmp_seq=1 ttl=46 time=15.9 ms

采用以下配置:

bernard@vbox11:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:b5:98:0b  
          inet addr:192.168.1.86  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feb5:980b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5028 errors:0 dropped:26 overruns:0 frame:0
          TX packets:756 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:494416 (494.4 KB)  TX bytes:51946 (51.9 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3033 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3033 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:246037 (246.0 KB)  TX bytes:246037 (246.0 KB)

和路由表:

bernard@vbox11:/etc/network$ ip route show
default via 192.168.1.1 dev eth0 
169.254.0.0/16 dev eth0  scope link  metric 1000 
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.86 

和主持人:

bernard@vbox11:/etc$ cat hosts
127.0.0.1   localhost
127.0.1.1   vbox11

# 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

和接口:

bernard@vbox11:/etc/network$ cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
dns-nameservers 192.168.1.70 192.168.1.1

auto eth0
iface eth0 inet static
address 192.168.1.86
netmask 255.255.255.0
gateway 192.168.1.1

在对接口文件进行更改后,我更新了使用:

sudo restart network-manager

根据 Marius Matutiae 的建议,dns-names 应该是 eth0 的一部分而不是 lo,我将接口更改为:

bernard@vbox11:/etc/network$ cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.86
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.70 192.168.1.1

刷新设置,并再次检查 Google,但没有成功:

bernard@vbox11:/etc/network$ sudo restart network-manager
network-manager start/running, process 3250
bernard@vbox11:/etc/network$ ping www.google.com
ping: unknown host www.google.com

所以我肯定在某个地方犯了错误。使用本地 DNS 作为主 DNS 和网关 DNS 作为辅助 DNS 的服务器工作正常,因为它确实适用于 Vbox1a。对我来说,设置看起来非常相似。我肯定在某个地方犯了错误,但不知道在哪里,也不知道如何搜索。

相关内容