Skip to content

Access running WSL services from LAN devices without having to create Firewall rules with networkingMode=mirrored #10769

Open

Description

Is your feature request related to a problem? Please describe.

This video demo of the new networkingMode = mirrored (at around 8:19 minutes) seems to suggest that services running inside WSL can be accessed from other devices on the same LAN without needing any extra setup. But in my experience LAN devices cannot access WSL services until you explicitly allow that port in the firewall rule.

I tried toggling the new experimental.firewall/wsl2.firewall, but it doesn't seem to make any difference.

Describe the solution you'd like

I think one of these solution should work:

  1. Let the user disable Firewall for WSL. (I expected experimental.firewall = false to do this)
  2. If firewall rules cannot be turned off completely for WSL, auto manage firewall rules for each service running within WSL, and prompt the user for consent if necessary.

Additional Details:

WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.2506
$ wslinfo --networking-mode
mirrored

Activity

  1. github-actions commented on Nov 16, 2023

    @github-actions
    Contributor

    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:

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

  2. changed the title [-]Access running WSL services from LAN devices without having to create Firewall rules[/-] [+]Access running WSL services from LAN devices without having to create Firewall rules with `networkingMode=mirrored`[/+] on Nov 16, 2023
  3. tusharsnx commented on Nov 16, 2023

    @tusharsnx
    Author

    #10714 The issue is closely related, but I'm sure the issuer was confused about whether creating a firewall rule is necessary or not. So I created this issue as a feature request rather than a bug.

  4. tusharsnx commented on Nov 17, 2023

    @tusharsnx
    Author

    Turns out that this article describes how you can disable WSL VM's Hyper-V Firewall in two steps:

    Warning

    Disabling Firewall can have unintended consequences. Any malicious app running within wsl gets unrestricted access to internet.

    1. Get WSL VM Id:
    $ Get-NetFirewallHyperVVMCreator
    
    VMCreatorId  : {40E0AC32-46A5-438A-A0B2-2B479E8F2E90}
    FriendlyName : WSL
    1. Disable Firewall (from an elevated/admin Terminal):
    $ Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Enabled False

    At this point, you should be able to access wsl services from other devices on LAN (or from the internet who knows 🙃).

  5. tusharsnx commented on Nov 17, 2023

    @tusharsnx
    Author

    A safer alternative is to Only allow connection to wsl in a Trusted (Private) network:

    New-NetFirewallHyperVRule `
    -DisplayName 'Allow All Inbound Traffic to WSL in Private Network' `
    -Name 'WSL Rule' `
    -Profiles Private `
    -Direction Inbound `
    -Action Allow `
    -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' `
    -Enabled True

    This would block connection to wsl in a public (or untrusted) network, which is good.

    In case you want to delete the rule, run:

    Remove-NetFirewallHyperVRule -Name 'WSL Rule'
  6. illgitthat commented on Nov 29, 2023

    @illgitthat

    I experienced the same issue (saw the demo video, tried a bunch of things but couldn't get it to work). This firewall rule accomplished just what I was looking for. Thank you Tushar Singh (@tusharsnx) !

    I agree that this needs to be incorporated by default or at least mentioned in the documentation.

  7. tusharsnx commented on Nov 28, 2024

    @tusharsnx
    Author

    Craig Loewen (@craigloewen-msft), could an option for the firewall's default behavior be added to the WSL Settings app or in .wslconfig?

    The need to create a firewall rule for connecting with devices on LAN has already been added to the docs. Thanks

  8. PoProstuWitold commented on Dec 23, 2024

    @PoProstuWitold

    Both solutions (disabling WSL VM's Hyper-V Firewall & creating rule for access) stopped working for me today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions