WSL: Fix the Internet Connection while on VPN

Based on this comment, the following instructions worked for me on Ubuntu Linux:

In your WSL Linux instance, create or edit /etc/wsl.conf to look like this:

[network]
generateResolvConf = false

Back in Windows, restart WSL using PowerShell:

wsl --shutdown
wsl

In your WSL Linux, create or edit /etc/resolv.conf to use Google Public DNS by creating the following entry (you may or may not have to delete other entries to get it working):

nameserver 8.8.8.8

Restart WSL again in PowerShell:

wsl --shutdown
wsl

Finally, once connected to the VPN, run the following command in Windows PowerShell, substituting <vpn name> with your VPN's name:

Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "<vpn name>"} | Set-NetIPInterface -InterfaceMetric 6000

For example, if your VPN's name is Cisco AnyConnect, the command would look like this:

Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000

Broader Topics Related to Fix the Windows Subsystem for Linux internet connection while on VPN

Windows Subsystem for Linux (WSL)

Windows Subsystem for Linux (WSL)

Tips and tricks for using Windows Subsystem for Linux (WSL)

Fix the Windows Subsystem for Linux internet connection while on VPN Knowledge Graph