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

WSL mirrored networking + VS Code WSL extension #11184

Open
bamurtaugh opened this issue Feb 20, 2024 · 16 comments
Open

WSL mirrored networking + VS Code WSL extension #11184

bamurtaugh opened this issue Feb 20, 2024 · 16 comments
Assignees
Labels

Comments

@bamurtaugh
Copy link
Member

As discussed on GitHub and offline, creating an issue to track VS Code user feedback that users are experiencing issues with WSL mirrored networking.

Here's the issue: microsoft/vscode-remote-release#9222. Here is an example of traces/logs: microsoft/vscode-remote-release#9222 (comment).

cc @craigloewen-msft

Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@diagonjope
Copy link

WslLogs-2024-07-16_13-02-22.zip

@aeschli the wsl netwroking log file is 126 MB. Github has a max allowance of 25 MB. Where should I drop the log

@aeschli
Copy link

aeschli commented Jul 16, 2024

@keith-horton
Copy link
Member

Can you please share your VSCode configuration / docker configuration / docker-desktop configuration?

We have tested with a few VSCode configurations and haven't repro'd issues.

If the log is too large, can you share through onedrive / google drive?

It's not clear why the trace would be that huge though :)

I would recommend:

  • start the trace
  • wsl --shutdown
  • launch VS
  • repro the problem
  • stop the trace

@diagonjope
Copy link

Greetings @keith-horton !

Here you go:

WslNetworkingLogs-networkingMode_mirrored_disabled_2024-07-18_16-00-23.zip

WslNetworkingLogs-networkingMode_mirrored_enabled_2024-07-18_15-58-08.zip

Docker_settings.json

VSCode_settings.json

Let me know if you need anything else from me.

Cheers,

++José

@CatalinFetoiu
Copy link
Collaborator

thanks for sending the logs

unfortunately the tcpdump packet capture was not collected (the tcpdump.log file in the zip is empty)

could you please check if you have tcpdump installed in your linux distribution. if not, can you please install tcpdump and collect the logs again?

in the stackoverflow link, you shared VSCode terminal output and renderer.log file in the VSCode logs - can you please share those again for the latest repro? they showed some network connections timing out, that information will be helpful to narrow down the logs

thanks

@diagonjope
Copy link

diagonjope commented Jul 19, 2024

@netux
Copy link

netux commented Sep 21, 2024

Just chipping in for people looking as to why VSCode fails to connect when WSL is configured with networkingMode=mirrored.
I was looking at the docs in Microsoft's website[^1] and noticed there is a note about running some commands to allow the firewall to accept inbound connections from WSL:

Run the following command in PowerShell window with admin privileges to Configure Hyper-V firewall settings to allow inbound connections: Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow or New-NetFirewallHyperVRule -Name "MyWebServer" -DisplayName "My Web Server" -Direction Inbound -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Protocol TCP -LocalPorts 80.

The documentation doesn't go into detail as to what exactly Set-NetFirewallHyperVVMSetting/New-NetFirewallHyperVRule do, but my guess is the first command disables the firewall for any connections coming from WSL, while the second one does the same but only for TCP connections on port 80.

I ran the first command and, after restarting the WSL distro, VSCode was able to connect to it again 🙂

[1]: https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking

@keith-horton
Copy link
Member

Hi there.

Yep, your understanding is very close.

Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow

This sets the default to Allow any inbound connection -- but if there are Block rules for inbound connections, those will still apply.

@FvTao
Copy link

FvTao commented Nov 25, 2024

The environment is as follows:

Version: Windows 11 Professional
Build: 23H2
Installation Date: November 6, 2024
Operating System Version: 22631.4317
Experience: Windows Feature Experience Pack 1000.22700.1041.0

PS C:\Users\root> wsl -v
WSL Version: 2.3.26.0
Kernel Version: 5.15.167.4-1
WSLg Version: 1.0.65
MSRDC Version: 1.2.5620
Direct3D Version: 1.611.1-81528511
DXCore Version: 10.0.26100.1-240331-1435.ge-release
Windows Version: 10.0.22631.4317

PS C:\Users\root> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-22.04    Stopped         2



[wsl2]
memory = 24GB
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
[experimental]
hostAddressLoopback=true

I have already executed Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow.

Cannot connect to WSL with mirrored networking.

When configuring networkingMode=mirrored, Visual Studio Code keeps showing "Connecting..."

@rbcb-bedag
Copy link

Hi

Also tried out to execute the firewall command from above. Still VSCode needs long time to load up a repository inside the wsl 2 instance.
Only when removing networking=mirrored from the .wslconfig, then it works again.
But would really like to use the mirrored mode.

Also tried with firewall=false in the .wslconfig, but didnt helped.

C:\Users\rbcb>wsl --version
WSL version: 2.3.26.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4602

Does somone else has still this problem or has a workaround for it ?

@diagonjope
Copy link

Hi @rbcb-bedag ,

I can confirm that I am still having the same problems as you are. If I commenting out the networking=mirrored from the .wslconfig file I can access the VS Code server, but then I can't access Internet sites from the Ubuntu session. I have the following configuration:

PowerShell 7.4.6
PS C:\Users\josep> Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow
PS C:\Users\josep> wsl --version
WSL version: 2.3.26.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.2605

@rbcb-bedag
Copy link

@netux Can you maybe share which version of wsl you use and how your .wslconfig file looks like ?
thx !

@netux
Copy link

netux commented Jan 9, 2025

@netux Can you maybe share which version of wsl you use and how your .wslconfig file looks like ? thx !

@rbcb-bedag Sure! Seems like I disabled dnsTunneling at some point. Not sure if that's relevant:

# On Windows
$ wsl --version
WSL version: 2.3.26.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4602

$ cat (windows user dir)\.wslconfig
[wsl2]
memory=24GB
processors=8

networkingMode=mirrored
; dnsTunneling=true

# On WSL Distro
$ cat ~/.wslconfig
[wls2]
# Leave 4GB for other stuff on the machine...
#memory=28GB

$ cat /etc/wsl.conf
[user]
default=netux

[automount]
options = "metadata"

@JacobBumgarner
Copy link

JacobBumgarner commented Jan 9, 2025

I can also confirm that I tried running the firewall update commands [1] but can't access WSL2 via VSCode WSL extension.

My .wslconfig file only contains:

[wsl2]
networkingMode=mirrored

WSL Version:

> wsl --version
WSL version: 2.3.26.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4602

WSL extension info:

Identifier
ms-vscode-remote.remote-wsl
Version
0.88.5
Last Updated
2025-01-09, 02:11:22

[1] https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking

@onedaxter
Copy link

Hi

Im also experiencing this problem with mirrored mode. Turning it off makes vscode work normal, but then my developing setup doesnt work anymore as i would like (thats another story...)

@bamurtaugh
@craigloewen-msft
Can you give us some suggestion what we can try out for fixing this problem with VSCode or how the community can help you ?

Thx

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