WSL下用VPN也连不github,是DNS的问题
https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#wsl-has-no-network-connectivity-once-connected-to-a-vpn
WSL has no 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.
Take a note of the DNS server of the VPN from doing ipconfig.exe /all Make a copy of the existing resolv.conf sudo cp /etc/resolv.conf /etc/resolv.conf.new Unlink the current resolv.conf sudo unlink /etc/resolv.conf sudo mv /etc/resolv.conf.new /etc/resolv.conf Edit /etc/wsl.conf and add this content to the file. (More info on this set up can be found in Advanced settings configuration)
Copy [network] generateResolvConf=false 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:
cd /etc sudo mv resolv.conf resolv.conf.new sudo ln -s ../run/resolvconf/resolv.conf resolv.conf
基本意思就是连了VPN,WSL系统里的DNS解析文件resolve.conf是自动生成的,DNS还是原来的,要换VPN上用的。
结果我用的这个VPN,连上以后也还是用的原来的DNS。
所以,按上面的步骤,搞个新的resolv.conf,最上面一条填个8.8.8.8的就行了,断开vpn后也不用改回去。