microsoft / microsoft/WSL

WSL2 gets the broadcast (.255) IP from the Hyper-V Adapter.

Open
#12,256 14 comments 0 reactions 1 assignee Claimed by @CatalinFetoiu View on GitHub
network question
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

We are using the inofficial registry keys to fix the IP range for WSL. For this, we use the following script:
```powershell
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss' -Name 'NatGatewayIpAddress' -Value '10.20.30.1' -PropertyType String -Force;
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss' -Name 'NatNetwork' -Value '10.20.30.0/24' -PropertyType String -Force;
```
This worked good so far but not we have one case, where the IP inside WSL for `eth0` is the broadcast IP (10.20.30.255) which I think leads to the networking issues this user has.

The output from `ip addr show` is like:
```
2: eth0: mtu 1280 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:8c:80:00 brd ff:ff:ff:ff:ff:ff
inet 10.20.30.255/24 brd 10.20.30.255 scope global eth0
valid_lft forever preferred_lft forever
```
The WSL instance indeed is not able to do any networking and I suspect this is because of the IP it got. We tried getting a new IP from DHCP (`dhclient -r`) but that didn't do anything. Also restarting and even re-creating the WSL2 (Debian) from scratch did not help.

Is there maybe a possible issue that WSL wrongly uses the broadcast address? Also is there any way to fix this for this user?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.