On a Windows 11 machine I have my regular wifi interface (192.168.3.7) and a Wintun Tunnel interface (configured to have IP 192.168.3.6). The routing tables are set up so that all traffic should go to the Wintun Tunnel by default. However I'd like to make some connections use the wifi interface. I tried creating a socket and binding it to that interface's IP, but the traffic is still routed to Wintun. Are there other settings somewhere that affect routing decisions? Note that this setup works as expected on another Windows 11 machine, so I think it may be due to some unusual setting on the affected machine.
Example Python code for how I create the socket and bind it to the wifi interface:
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
Routing info:
===========================================================================
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
0.0.0.0
routes, meaning two default routes. The one to gateway192.168.3.6
has the metric6
, while the one to gateway192.168.3.7
has the metric30
. As the lower metric has the priority, gateway192.168.3.6
is the referred route. The question is rather how does it work correctly on the other computer.