I have installed WSL2 on a virtual machine running Windows Server 2022 Datacenter. My VM connects to the internet via a corporate proxy, but I am unable to access the internet from WSL2.
System Details:
- WSL version: 2.4.11.0
- Kernel version: 5.15.167.4-1
- Windows version: 10.0.20348.3207 (Windows Server 2022 Datacenter, Version 21H2)
What I Have Tried:
Checked Networking Mode: Attempted to enable mirrored networking mode, but it is not supported on Windows Server 2022 Build 20348.3207.
Configured DNS (resolv.conf): Set my company’s proxy as the nameserver in /etc/resolv.conf.
Proxy Configuration:Tried setting proxy settings in WSL using:
export http_proxy="http://companyproxy.example.com:port"
export https_proxy="http://companyproxy.example.com:port"
Also added these settings to ~/.bashrc and ~/.profile.
Issue: When running sudo apt update, I receive the following errors:
- Err:1 http://security.ubuntu.com/ubuntu noble-security InRelease Cannot initiate the connection to security.ubuntu.com:80 (Network is unreachable)
- Err:2 http://archive.ubuntu.com/ubuntu noble InRelease Cannot initiate the connection to archive.ubuntu.com:80 (Network is unreachable) It appears that WSL2 cannot reach the internet even though my Windows VM can.
Questions:
- How can I properly configure networking for WSL2 in a Windows Server 2022 VM?