Friday, October 21, 2022

No internet Connection from WSL2

I was facing an issue while connecting to the internet from WSL2 on a Windows 10 machine; the ping and telnet were both not working.

Followed the below steps to resolve the problem

Execute the ipconfig command in PowerShell



Execute the below command on WSL2

sudo ifconfig eth0 172.20.100.5 netmask 255.255.240.0

sudo route add default gw 172.20.100.1


172.20.100.1 - default gw address

172.20.100.5 - Select an IP address within the same range

255.255.240.0 - netmask


Execute the below command on PowerShell

wsl --shutdown

Now open the WSL terminal. You should be able to connect to the internet.



No comments:

Post a Comment