- 地位
- 我的电脑有一个 Hyper-V VM 和一个 WSL 实例,它们的 IP 地址分别为
192.168.254.30
和192.168.254.20
。 - 目标是建立从 WSL 到 Hyper-V VM 的 TCP 连接,但 PC 无法路由到 VM。
- WSL 实例
#ifconfig
...
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.50.39 netmask 255.255.240.0 broadcast 192.168.63.255
inet6 fe80::215:5dff:fe91:7e17 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:91:7e:17 txqueuelen 1000 (Ethernet)
RX packets 80470 bytes 119447117 (119.4 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13016 bytes 1130767 (1.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.254.20 netmask 255.255.255.0 broadcast 192.168.50.255
ether 00:15:5d:91:7e:17 txqueuelen 1000 (Ethernet)
...
- Hyper-V
Ethernet adapter Default:
Connection-specific DNS Suffix . : mshome.net
Link-local IPv6 Address . . . . . : fe80::aca0:3022:c8b1:fef%17
IPv4 Address. . . . . . . . . . . : 172.19.127.44
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . : 172.19.112.1
Ethernet adapter WSL:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::24f7:b664:6f15:ccf%27
IPv4 Address. . . . . . . . . . . : 192.168.48.30
Subnet Mask . . . . . . . . . . . : 255.255.240.0
IPv4 Address. . . . . . . . . . . : 192.168.254.40
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.254.100
192.168.48.1
tracert
从电脑
> tracert 192.168.254.20
최대 30홉 이상의 192.168.254.20(으)로 가는 경로 추적
1 <1 ms <1 ms <1 ms 192.168.254.20
추적을 완료했습니다. #Tracing done.
> tracert 192.168.254.30
최대 30홉 이상의 192.168.254.30(으)로 가는 경로 추적
1 <1 ms <1 ms <1 ms 172.25.18.2
2 1 ms 1 ms 1 ms 172.25.255.153
3 1 ms 1 ms 1 ms 172.28.255.49
...
- PC中的路由表
IPv4 route table
===========================================================================
active routes:
network target network mask gateway interface metric
...
192.168.254.0 255.255.255.0 connected 192.168.48.1 5256
...
ipconfig
VM 中的设置
Ethernet adapter WSL:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::24f7:b664:6f15:ccf%27
IPv4 Address. . . . . . . . . . . : 192.168.48.30
Subnet Mask . . . . . . . . . . . : 255.255.240.0
IPv4 Address. . . . . . . . . . . : 192.168.254.40
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.254.100
192.168.48.1
奇怪的是, 中未使用的地址192.168.254.0/24
被路由到192.168.254.100
。
> tracert 192.168.254.50 <----- no server is using this
최대 30홉 이상의 192.168.254.50(으)로 가는 경로 추적
1 john-doe-pc [192.168.254.100] report: cannot connect to the host.
tracing done.
如果我将 Hyper-V VM 的 IP 地址更改为此192.168.254.50
,PC 就会开始192.168.254.50
通过此路由172.25.18.2
,即到互联网的路由。我必须在 VM 中执行某些操作吗?