Last active
April 24, 2024 19:34
-
-
Save chrisfranko/2652a86683b66ba0ff67e6759a3d5797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
If you are running WSL2 on Windows 11 22H2 or higher, you can now use mirrored mode networking. | |
In your %USERPROFILE%\.wslconfig file in Windows (create it if it doesn't exist), add the line networkingMode=mirrored under [wsl2]. | |
Allow inbound connections through the Hyper-V firewall. This can be done by running one of the following commands in PowerShell with administrator privileges. | |
One port or range of ports: | |
```New-NetFirewallHyperVRule -DisplayName "WSL SSH" -Direction Inbound -VMCreatorId "{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}" -Protocol TCP -LocalPorts 22``` | |
Change -DisplayName to your desired value and -LocalPorts to your desired port or range of ports | |
All ports: | |
```Set-NetFirewallHyperVVMSetting -Name "{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}" -DefaultInboundAction Allow``` | |
Run WSL with the new config, for example using wsl --shutdown and then wsl to restart it. | |
This should be enough to allow connections to sshd and other WSL-hosted servers over LAN. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment