How can WSL have access to Internet when the GlobalProtect VPN is activated on Microsoft Windows 10?

Franck Dernoncourt

I use GlobalProtect VPN 5.2.12-16 and Windows Subsystem for Linux (WSL) 2004.2022.1.0 on Microsoft Windows 10 Enterprise 21H1 19043.1766. WSL doesn't have access to Internet when the GlobalProtect VPN is on. How can I fix that?

Franck Dernoncourt

https://github.com/microsoft/WSL/issues/5068 mentions that this is a bug in WSL2 and point to the following workaround https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#bash-loses-network-connectivity-once-connected-to-a-vpn:

If after connecting to a VPN on Windows, bash loses network connectivity, try this workaround from within bash. This workaround will allow you to manually override the DNS resolution through /etc/resolv.conf.

  1. Take a note of the DNS server of the VPN from doing ipconfig.exe /all

  2. Make a copy of the existing resolv.conf sudo cp /etc/resolv.conf /etc/resolv.conf.new

  3. Unlink the current resolv.conf sudo unlink /etc/resolv.conf

  4. sudo mv /etc/resolv.conf.new /etc/resolv.conf

  5. Edit /etc/wsl.conf and add this content to the file. (More info on this set up can be found in Advanced settings configuration)

    [network]
    generateResolvConf=false
    
  6. Open /etc/resolv.conf and
    a. Delete the first line from the file which has a comment describing automatic generation
    b. Add the DNS entry from (1) above as the very first entry in the list of DNS servers.
    c. Close the file.

Once you have disconnected the VPN, you will have to revert the changes to /etc/resolv.conf. To do this, do:

  1. cd /etc
  2. sudo mv resolv.conf resolv.conf.new
  3. sudo ln -s ../run/resolvconf/resolv.conf resolv.conf

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

When VPN is on in WSL2, how can I ping windows from WSL2

How to remove microsoft (work) account on Windows 10 when I have no longer access to it?

Windows 10 PPTP VPN No Internet

Access internet when connected to VPN

No internet access when VPN connected

How can I change the location of docker images when using WSL2 with Windows 10 Home?

How to access linux/Ubuntu files from Windows 10 WSL?

How to make sure use one IP access Internet firstly, when a Windows Server have multi IP addresses?

How can I access servers on my network when connected to a VPN?

How can we update email in GlobalProtect?

How can I get my Windows 7 serial key (when I have upgraded to Windows 10)?

How to allow ubuntu in virtualbox access to internet while windows host is connected to VPN?

In Windows 10 using Microsoft Edge when viewing a PDF how can you navigate to a specific page number?

Windows 10 slow internet download, WSL 2.0 however is fast

How to debug: ping "Name or service not known" with Ubuntu 20.04 in WSL1 in Windows 10, even with required nameserev settings for VPN?

Wireguard VPN, no Internet access

Can't connect to VPN on Windows 10

Is it possible install Ubuntu in Windows 10 WSL without Microsoft Store?

Create folder from Windows then access from Bash in Windows 10 WSL

How can I access windows 10 partition in ubuntu when i cant get it to shut down in a "safe state"?

Windows 10: How can I fix "access denied" when using mkdir

Block internet access to KM Player in windows 10

How to set the `WSL` password from Windows 10?

How to enable a button only when two comboboxes have been activated

How can I change the text cursor speed in Microsoft Windows 10?

How can I find the Microsoft Edge version on Windows 10 in powershell?

How to dual boot windows 10 Pro , Ubuntu and bitlocker activated

How can I access the internet?

How to fix 'Microsoft Access can't be started. Microsoft Access was unable to initialize the Windows Registry'?