← Back to blog

Windows 多网卡 VPN 路由冲突解决方案

Markdown · 经验心得 · 06/12/2026, 09:37 AM

#路由#网卡#VPN#Windows

一、 问题描述

在多网卡(有线 + 无线 + VPN)共存的 Windows 环境中,出现以下现象:

现象:能 Ping 通内网服务器 10.87.9.200,Telnet 测试 443端口也显示通畅,但浏览器或应用无法通过 HTTPS 访问。

环境

  • 无线网卡:用于上网(如 192.168.3.9)。

  • 有线网卡:用于连接本地设备(IP: 10.87.9.102)。

  • VPN 虚拟网卡:用于访问公司内网(拨号后获得 10.77.x.x地址)。

原因:企业 VPN 客户端拨号后,会强制向系统路由表注入指向 10.87.9.0/24网段的路由规则,且其跃点数(Metric)优先级高于本地有线网卡的直连路由。导致访问本地设备的流量被错误引流至 VPN 隧道,被服务器拒绝连接(Connection Reset)。

二、 解决方案:精确路由劫持(最小影响范围)

采用 “最长前缀匹配(Longest Prefix Match)” 原则,不删除 VPN 原有路由,而是针对故障目标 IP 单独下发一条精度最高(/32)的静态直连路由,强制指定出口。

1. 确认有线网卡接口 ID (Interface Index)

管理员身份打开 CMD 或 PowerShell,执行:

netsh interface ipv4 show interfaces

记录有线网卡对应的 Idx编号(本例中为 19)。

C:\Users\Hillstone>netsh interface ipv4 show interfaces

Idx     Met         MTU          状态                名称
---  ----------  ----------  ------------  ---------------------------
  1          75  4294967295  connected     Loopback Pseudo-Interface 1
  6          65        1500  disconnected  蓝牙网络连接
 40           1        1500  connected     UESVirtualNet
  8          30        1500  connected     WLAN
 10           5        1500  disconnected  以太网
 16          25        1500  disconnected  本地连接* 9
 15          25        1500  disconnected  本地连接* 10
 19          10        1500  connected     以太网 2

image-20260518145120961

2. 添加永久精确路由

执行以下命令,将目标 IP 10.87.9.200的流量强制绑定到有线网卡(ID 19)直连出去:

netsh interface ipv4 add route 10.87.9.200/32 interface=19 metric=1 store=persistent
  • 10.87.9.200/32:精确到单个 IP,优先级最高。

  • interface=19:指定走有线网卡(请替换为你的实际 ID)。

  • metric=1:跃点数为 1,确保最高优先级。

  • store=persistent:写入注册表,重启或重拨 VPN 仍生效。

PS C:\Users\Hillstone> netsh interface ipv4 add route 10.87.9.200/32 interface=19 metric=1 store=persistent
确定。

image-20260518145243548

3. 验证结果

执行 route print | findstr "10.87.9",应看到如下结果:

C:\Users\Hillstone>route print | findstr "10.87.9"
		网络目标        网络掩码         		 网关       	  接口   			跃点数
        10.87.9.0    255.255.255.0            在链路上       10.87.9.102    281
        10.87.9.0    255.255.255.0       10.77.64.1     10.77.64.118     35
      10.87.9.102  255.255.255.255            在链路上       10.87.9.102    281
      10.87.9.200  255.255.255.255            在链路上       10.87.9.102     26
      10.87.9.255  255.255.255.255            在链路上       10.87.9.102    281
        224.0.0.0        240.0.0.0            在链路上       10.87.9.102    281
  255.255.255.255  255.255.255.255            在链路上       10.87.9.102    281
      10.87.9.200  255.255.255.255            在链路上        1

关键点10.87.9.200的掩码为 255.255.255.255(精确匹配),且网关为“在链路上”。

image-20260518145527137

三、 后续维护

若日后不再需要访问该设备,或需清理路由,可删除该规则:

netsh interface ipv4 delete route 10.87.9.200/32 interface=19 store=persistent