1

有一种情况:有 2 台虚拟计算机(定义为 A 和 B),每台运行 Ubuntu 16.04。对它们进行网络配置:

Adapter1 : Host-only with Promiscuous Allow All
Adapter2:  Nat Network with Promiscuous Allow VM's

两台电脑的mac地址不同

PC A :
仅主机适配器与 mac(080027B2EBC7)
NAT 网络适配器与 mac(0800273F605C)

PC B:
host onlt 适配器 with mac( 0800272DC6FF)
Nat 网络适配器 with mac( 080027B8CEC1)

计算机 A:通过终端发送 ping 命令:

ping google.com

当计算机 A 正在 ping 计算机 B 上打开的 wireshark 时。

我在 PC B 的 Wireshark 上看不到我从 PC A 发送的 icmp 数据包。

两台 PC 的 ifconfig:

A:

    enp0s3    Link encap:Ethernet  HWaddr 08:00:27:b2:eb:c7  
          inet addr:192.168.56.103  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::717a:1d3f:cf7d:a25f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:83 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8788 (8.7 KB)  TX bytes:6807 (6.8 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:3f:60:5c  
          inet addr:10.0.2.4  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::955f:36a:18c3:706f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2689 (2.6 KB)  TX bytes:7197 (7.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:71 errors:0 dropped:0 overruns:0 frame:0
          TX packets:71 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:21609 (21.6 KB)  TX bytes:21609 (21.6 KB)

乙:

   enp0s3    Link encap:Ethernet  HWaddr 08:00:27:2d:c6:ff  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::ca16:a283:da31:e0a2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:97 errors:0 dropped:0 overruns:0 frame:0
          TX packets:55 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11541 (11.5 KB)  TX bytes:6333 (6.3 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:b8:ce:c1  
          inet addr:10.0.2.7  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::b3c3:7fd:e18c:ccd3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:54 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7449 (7.4 KB)  TX bytes:6511 (6.5 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:95 errors:0 dropped:0 overruns:0 frame:0
          TX packets:95 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 

也许我对虚拟机网络的想法有错误的理解。

感谢您的帮助

4

1 回答 1

1

您没有清楚地说明您的问题,但我认为您想查看 VM-B 上的 ICMP 流量,当您从 VM-A ping google 时,如果是这样,那么您有一个错误:

您可以通过它访问 VM-B的仅主机适配器不适用于外部/外部/公共(更清楚的)网络。

您可以使用此命令检查哪个 iface 用于路由:

ip route get $(host google.com | head -n1 | grep -oP '[0-9][0-9\.]+')

如果你想让它路由为 VM-A -> VM-B -> 互联网,那么你必须为此创建默认(或专用)路由

于 2018-12-10T07:09:40.700 回答