Source: Chatgpt
Installed wsl ubuntu on win 11. cannot access lan from bash
On Windows 11, WSL2 normally can access your LAN through Windows NAT. If Ubuntu can reach the internet but cannot reach machines on your local network, the usual causes are the Windows firewall, VPN/security software, or WSL’s networking mode.
First, from Ubuntu, test these separately:
# Check the WSL network
ip addr
ip route
# Internet by IP
ping -c 3 1.1.1.1
# Internet by DNS
ping -c 3 google.com
# Your Windows host as seen from WSL
ip route | grep default
# A LAN device — substitute a real LAN IP
ping -c 3 192.168.1.10
The important distinction is whether 192.168.1.10 fails while 1.1.1.1 works.
Recent WSL versions work better on LANs with mirrored networking rather than the older NAT configuration.
On Windows, create or edit:
C:\Users\<your-user>\.wslconfig
with:
[wsl2]
networkingMode=mirrored
Then from PowerShell:
wsl --shutdown
Start Ubuntu again and test:
ping -c 3 192.168.1.10
Mirrored mode is particularly useful when you need WSL to access SMB servers, NAS devices, printers, web servers, SSH hosts, etc. on the same LAN.
In PowerShell:
wsl --version
wsl --status
Also:
wsl -l -v
You should see Ubuntu running as version 2, for example:
NAME STATE VERSION
Ubuntu Running 2
If you have an old WSL installation, update it:
wsl --update
wsl --shutdown
Try a specific TCP service instead of relying on ping, because Windows or the target device may block ICMP.
For example:
curl http://192.168.1.10/
or:
ssh user@192.168.1.10
or for SMB:
nc -vz 192.168.1.10 445
Also check the route:
ip route
With traditional NAT you might see something like:
default via 172.25.64.1 dev eth0
172.25.64.0/20 dev eth0 proto kernel scope link src 172.25.70.123
That is normal; WSL does not need a 192.168.x.x address to access a 192.168.x.x LAN when using NAT.
If you paste the output of these four commands, I can identify exactly where it is failing:
ip addr
ip route
ping -c 2 1.1.1.1
ping -c 2 <IP-of-one-of-your-LAN-devices>