- 1 year ago
connect to server running under wsl 1 from another machine
To connect to a server running under Windows Subsystem for Linux (WSL) 1 from another machine on the same network, you can follow these steps:
Enable WSL and Install a Linux Distribution: Make sure WSL is enabled on your Windows machine and install a Linux distribution of your choice (e.g., Ubuntu, Debian) from the Microsoft Store.
Set Up WSL Networking:
- Open a Command Prompt or PowerShell window as an administrator.
- Run the following command to configure WSL to use a static IP address:
Replacearduinowsl --set-version <distribution name> 1
<distribution name>
with the name of your installed Linux distribution (e.g., Ubuntu-20.04). - Start the WSL distribution by launching it from the Start menu or using the
wsl
command in the Command Prompt or PowerShell.
Obtain the IP Address of the WSL Instance:
- Inside the WSL distribution, run the following command to get the IP address assigned to the WSL instance:sql
ip addr show eth0
- Note down the IP address displayed in the output. It should be under the
inet
section, such as192.168.x.x
.
- Inside the WSL distribution, run the following command to get the IP address assigned to the WSL instance:
Configure Firewall and Network Access:
- Make sure the firewall on your Windows machine allows incoming connections to the WSL instance. You may need to create a rule to allow incoming traffic on the specific port you're using.
- Check the network settings of your router or network infrastructure to ensure that the required ports are open and forwarded to the IP address of your Windows machine.
Connect to the WSL Instance from Another Machine:
- From another machine on the same network, open a terminal or command prompt.
- Use an SSH client, such as
ssh
(Linux/Mac) or PuTTY (Windows), to connect to the IP address of your Windows machine using the WSL instance's IP address as the target.
Replacekotlinssh username@<windows-ip-address>
username
with your Windows username and<windows-ip-address>
with the IP address of your Windows machine.
Enter your Windows user password when prompted, and you should be connected to the WSL instance.
By following these steps, you should be able to connect to a server running under WSL 1 from another machine on the same network. Make sure to adjust the necessary firewall and network settings to allow the connection.