Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Roemer opened this issue Nov 11, 2024 · 6 comments
Closed

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

Roemer opened this issue Nov 11, 2024 · 6 comments
Labels

Comments

@Roemer
Copy link

Roemer commented Nov 11, 2024

We are using the inofficial registry keys to fix the IP range for WSL. For this, we use the following script:

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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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?

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

@Roemer
Copy link
Author

Roemer commented Nov 11, 2024

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

/question

Copy link

Diagnostic information
Found '/question', adding tag 'question'

@OneBlue
Copy link
Collaborator

OneBlue commented Nov 12, 2024

@Roemer: I'm surprised that you're getting 10.20.30.255 as an ip address here (this definitely would break networking). Could share /logs of a repro so we can see what happens then ?

@Roemer
Copy link
Author

Roemer commented Nov 13, 2024

I was not able to reproduce this anywhere and it worked for 40+ workstations just this one failed by getting the *.255 IP.

As the user was completely blocked, we searched for a workaround and found that the IP of the WSL Instance is stored in a registry key found in Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss in the key NatIpAddress which indeed was the *.255 IP. We shutdown WSL, adjusted the value to any valid IP for the defined range and started WSL again and everything started working.

So to reproduce that it is not working, one can just set this registry key to *.255. But I cannot reproduce how it got that IP in the first place.

@OneBlue
Copy link
Collaborator

OneBlue commented Nov 13, 2024

Well this would be expected, since a .255 ip address is a broadcast address, so networking can't function with it. I'll close this for now, but feel free to reopen if you reproduce WSL automatically generating a .255 ip address

@OneBlue OneBlue closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants