資料包採取哪條路徑?

資料包採取哪條路徑?

我已經在 VirtualBox 中設定了僅主機網路。

Windows 主機:

VirtualBox Host-Only Network
 IPv4 Address. . . . . . . . . . . : 192.168.56.1

Wireless LAN Adapter Wireless Network Connection 2
  IPv4 Address. . . . . . . . . . . : 172.19.156.59
  Subnet Mask . . . . . . . . . . . : 255.255.255.0
  Default Gateway . . . . . . . . . : 172.19.156.1

CentOS虛擬機器:

eth0      Link encap:Ethernet  HWaddr 08:00:27:AF:A3:28  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feaf:a328/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:381 errors:0 dropped:0 overruns:0 frame:0
          TX packets:423 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:56181 (54.8 KiB)  TX bytes:50846 (49.6 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:C4:A8:B6  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fec4:a8b6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8984 errors:0 dropped:0 overruns:0 frame:0
          TX packets:162 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1155253 (1.1 MiB)  TX bytes:31231 (30.4 KiB)

eth2      Link encap:Ethernet  HWaddr 08:00:27:DB:B6:AB  
          inet addr:10.0.4.15  Bcast:10.0.4.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fedb:b6ab/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:220 errors:0 dropped:0 overruns:0 frame:0
          TX packets:487 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:87762 (85.7 KiB)  TX bytes:37818 (36.9 KiB)

當我在 CentOS VM 中連接到互聯網時,我想查看封包通過哪條路徑到達 google.com,我可以 ping Windows 主機中的預設網關,我的主要興趣是查看封包如何到達那裡。

[root@localhost network-scripts]# traceroute -I 172.19.156.1
traceroute to 172.19.156.1 (172.19.156.1), 30 hops max, 60 byte packets
 1  172.19.156.1 (172.19.156.1)  1.182 ms  3.395 ms  0.825 ms
[root@localhost network-scripts]# traceroute -T 172.19.156.1
traceroute to 172.19.156.1 (172.19.156.1), 30 hops max, 60 byte packets
 1  172.19.156.1 (172.19.156.1)  14.336 ms  13.957 ms  19.046 ms
[root@localhost network-scripts]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
10.0.4.0        *               255.255.255.0   U     0      0        0 eth2
link-local      *               255.255.0.0     U     1002   0        0 eth0
link-local      *               255.255.0.0     U     1003   0        0 eth1
link-local      *               255.255.0.0     U     1004   0        0 eth2
192.168.56.0    *               255.255.255.0   U     0      0        0 eth1

我已使用 -I 和 -T 句柄作為透過 UDP 返回的預設追蹤路由 * 上述輸出是否意味著資料包直接從 10.0.2.2 發送到 172.19.156.1?

當嘗試traceroute -T 172.16.156.59(Windows主機)時,我也得到多個*

答案1

虛擬盒手冊關於 NAT 網路有這樣的說法:

VirtualBox 的 NAT 引擎接收來賓作業系統發出的網路幀,提取 TCP/IP 資料並使用主機作業系統重新傳送。對於主機上的應用程序,或與主機位於同一網路上的另一台計算機,資料看起來像是由主機上的 VirtualBox 應用程式使用屬於該主機的 IP 位址發送的。

因此,我相信來自虛擬機器的任何透過其NAT 介面的追蹤路由都會報告與主機上運行的追蹤路由相同的一組網關,這意味著追蹤路由不會列出VirtualBox NAT 網關,也不會列出主機上的介面用於從主機發送流量。

相關內容