虚拟机无法互相 ping 通

虚拟机无法互相 ping 通

我在 virt-manager 中创建了两台虚拟机。所有机器(主机和客户机)都运行 Ubuntu 14.04。

主机有两个网卡。eth1 由主机使用。每个 VM/guest 的虚拟网络接口设置为Host device eth0: macvtap

  • 主机 IP 为 192.168.1.35
  • 访客 1 的 IP 是 192.168.1.41
  • 访客 2 的 IP 是 192.168.1.54

我可以从客户机 ping 主机,也可以从主机 ping 客户机。但客户机之间无法互相访​​问。当我从客户机 1 ping 客户机 2 时,tcpdump主机的输出为:

17:55:11.631825 ARP, Request who-has 192.168.1.54 tell 192.168.1.41, length 28
17:55:12.631626 ARP, Request who-has 192.168.1.54 tell 192.168.1.41, length 28
17:55:13.632127 ARP, Request who-has 192.168.1.54 tell 192.168.1.41, length 28
...

类似地,当我从来宾 2 ping 来宾 1 时:

17:57:39.509281 ARP, Request who-has 192.168.1.41 tell 192.168.1.54, length 28
17:57:40.509280 ARP, Request who-has 192.168.1.41 tell 192.168.1.54, length 28
17:57:41.526726 ARP, Request who-has 192.168.1.41 tell 192.168.1.54, length 28
....

两位来宾都有以下网络配置:

/etc/network/interfaces
    auto lo
        iface lo inet loopback
    auto eth1
        iface eth1 inet dhcp

route -n
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth1
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1       

iptables -L
    (nothing)

ifconfig (Guest 1)
    eth1      Link encap:Ethernet  HWaddr 52:54:00:ab:e6:fa  
              inet addr:192.168.1.41  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::5054:ff:feab:e6fa/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:728 errors:0 dropped:0 overruns:0 frame:0
              TX packets:638 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:817117 (817.1 KB)  TX bytes:51190 (51.1 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:16 errors:0 dropped:0 overruns:0 frame:0
              TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:1184 (1.1 KB)  TX bytes:1184 (1.1 KB)

主持人:

/etc/network/interfaces
    auto lo
    iface lo inet loopback

route -n
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth1
    192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth1

iptables -L
    (nothing)

ifconfig
    eth0      Link encap:Ethernet  HWaddr 08:62:66:26:eb:d8  
              inet6 addr: fe80::a62:66ff:fe26:ebd8/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:218 errors:0 dropped:0 overruns:0 frame:0
              TX packets:110 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:67520 (67.5 KB)  TX bytes:20012 (20.0 KB)

    eth1      Link encap:Ethernet  HWaddr 70:62:b8:b5:2c:1b  
              inet addr:192.168.1.35  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::7262:b8ff:feb5:2c1b/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:4100 errors:0 dropped:0 overruns:0 frame:0
              TX packets:4678 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:1030310 (1.0 MB)  TX bytes:834427 (834.4 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:15192 errors:0 dropped:0 overruns:0 frame:0
              TX packets:15192 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:1386699 (1.3 MB)  TX bytes:1386699 (1.3 MB)

    macvtap0  Link encap:Ethernet  HWaddr 52:54:00:db:29:6c  
              inet6 addr: fe80::5054:ff:fedb:296c/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:19 errors:0 dropped:0 overruns:0 frame:0
              TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:2286 (2.2 KB)  TX bytes:5930 (5.9 KB)

    macvtap1  Link encap:Ethernet  HWaddr 52:54:00:ab:e6:fa  
              inet6 addr: fe80::5054:ff:feab:e6fa/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:29 errors:0 dropped:0 overruns:0 frame:0
              TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:4395 (4.3 KB)  TX bytes:7980 (7.9 KB)

答案1

用桥接接口替换 eth0 解决了这个问题。但是,还有另一个问题: 添加桥接接口时网速低

相关内容