Scenario
I am using Windows Subsystem for Linux (WSL) for my development work and I have a VPN client installed on my Windows machine. When I connect to the VPN, the internet stops working on WSL. However, the internet works fine on the Windows machine, but not on WSL.
Solution
Create a file %UserProfile%\.wslconfig with the content below, and then restart wsl.
[wsl2]
networkingMode=mirrored
dnsTunneling=true
Run wsl.exe --shutdownto restart WSL.
Ref: https://superuser.com/questions/1630487/no-internet-connection-ubuntu-wsl-while-vpn
Tip
Launching the WSL with root user always
Execute this in the Powershell
ubuntu config --default-user root