Windowsは「メトリック値(Metric)」という優先度に基づいて、どのインターフェースを使うかを決定します。
「インターフェース メトリック」に数値を入力(小さいほど優先される)
ForceBindIP(非OSS、Anonnymose) というツールを使えば、特定のIPアドレス(インターフェース)を使ってアプリを起動できます。
例:ForceBindIP.exe 192.168.43.131 "C:\Program Files\Google\Chrome\Application\chrome.exe"
これにより、Wi-Fi経由でChromeを起動可能。
https://github.com/haad/proxychains
https://github.com/diegocr/netcat
Pythonでアプリを自作ならBindIP、https://github.com/katlogic/bindip 起動時にバインドするIPを選択することで、指定したインターフェース経由で通信でき。
Met列がメトリック値(Metric) C:\Users\X270-P>netsh interface ipv4 show interface
| Idx | Met | MTU | 状態 | 名前 |
| --- | ---------- | ---------- | ------------ | --------------------------- |
| 1 | 75 | 4294967295 | connected | Loopback Pseudo-Interface 1 |
| 13 | 25 | 1500 | disconnected | McAfee VPN |
| 11 | 50 | 1500 | connected | Wi-Fi |
| 19 | 25 | 1500 | connected | イーサネット |
| 8 | 25 | 1500 | disconnected | ローカル エリア接続* 1 |
| 16 | 65 | 1500 | disconnected | Bluetooth ネットワーク接続 |
| 18 | 25 | 1500 | disconnected | ローカル エリア接続* 2 |
PS C:\Users\X270-P> Get-NetIPInterface | Where-Object InterfaceIndex -in 11,19 | Format-Table ifIndex,InterfaceAlias,InterfaceMetric,AddressFamily,ConnectionState -AutoSize
| ifIndex | InterfaceAlias | InterfaceMetric | AddressFamily | ConnectionState |
| ------- | -------------- | --------------- | ------------- | --------------- |
| 19 | イーサネット | 25 | IPv6 | Connected |
| 11 | Wi-Fi | 50 | IPv6 | Connected |
| 19 | イーサネット | 25 | IPv4 | Connected |
| 11 | Wi-Fi | 50 | IPv4 | Connected |
Idx指定で設定: netsh interface ipv4 set interface 11 met=20
netsh interface ipv6 set interface 11 met=20
または名前指定: netsh interface ipv4 set interface "Wi‑Fi" met=20
netsh interface ipv4 set interface "Wi‑Fi" met=20