WSL 无法连接到指定网卡

有时候在使用了V---P+++++N的时候会出现wsl不能走指定的网卡。
于是在Github搜索一圈以后发现这个方法是可以的

https://github.com/microsoft/WSL/issues/5068
I saw a pattern while using WSL 2 on cisco any connect vpn and tried this and looks to be working.
Disconnect from VPN, if you are connected.
Shutdown WSL 2
Login to VPN again
Run below command from powershell as administrator.
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Login to WSL 2, Hopefully you will have internet working.
This steps has to be repeated every time when switched on machine.

步骤

  1. 断开连接
  2. 关闭wsl wsl --shutdown
  3. 重新连接
  4. 用管理员方式打开powershell运行如下命令
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
  1. 重新打卡wsl
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注