在 Windows 11 机器上,我有常规 wifi 接口 (192.168.3.7) 和 Wintun Tunnel 接口 (配置为 IP 192.168.3.6)。路由表设置为默认情况下所有流量都应转到 Wintun Tunnel。但是我想让一些连接使用 wifi 接口。我尝试创建一个套接字并将其绑定到该接口的 IP,但流量仍然路由到 Wintun。是否有其他设置会影响路由决策?请注意,此设置在另一台 Windows 11 机器上按预期工作,因此我认为这可能是由于受影响机器上的一些不寻常的设置。
有关如何创建套接字并将其绑定到 wifi 接口的 Python 代码示例:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("192.168.3.7",0))
sock.connect(("www.google.com",80)) // these TCP packets still get sent to the Wintun Tunnel
路线信息:
===========================================================================
Interface List
11...........................Wintun Tunnel
9...ce 47 40 77 44 bc ......Microsoft Wi-Fi Direct Virtual Adapter
2...ee 47 40 77 44 bc ......Microsoft Wi-Fi Direct Virtual Adapter #2
8...cc 47 40 77 44 bc ......Realtek RTL8852BE WiFi 6 802.11ax PCIe Adapter
18...cc 47 40 77 44 bd ......Bluetooth Device (Personal Area Network)
1...........................Software Loopback Interface 1
===========================================================================
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.3.1 192.168.3.7 30
0.0.0.0 0.0.0.0 On-link 192.168.3.6 6
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
192.168.3.0 255.255.255.0 On-link 192.168.3.7 286
192.168.3.0 255.255.255.0 On-link 192.168.3.6 261
192.168.3.6 255.255.255.255 On-link 192.168.3.6 261
192.168.3.7 255.255.255.255 On-link 192.168.3.7 286
192.168.3.255 255.255.255.255 On-link 192.168.3.7 286
192.168.3.255 255.255.255.255 On-link 192.168.3.6 261
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 192.168.3.7 286
224.0.0.0 240.0.0.0 On-link 192.168.3.6 261
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 192.168.3.7 286
255.255.255.255 255.255.255.255 On-link 192.168.3.6 261
===========================================================================
Persistent Routes:
None