Configuration files that expose WSL2 to LAN.
@yoshipon is not an expert on network security, and the scripts possibly include security holes.
Any Issues and PRs to improve the security and usability are welcome :)
The main idea is to connect WSL2 to LAN through the Windows host by using VPN bridging to the physical NIC. This repository include
conf/server.ovpn: a configuration file for an OpenVPN server on the Windows hostconf/client.conf: a configuration file for an OpenVPN client on WSL2conf/wsl.conf: a configuration file for WSL to rename the hostname of WSL2bin/start-services.sh: a script file to start network services and obtain an IP address from a DHCP server
- Install OpenVPN on Windows host
- Put
server.ovpnon the configuration directory of OpenVPN (which may be found in your Start menu). - Make a directory
caon the configuration directory and generate the following key files:ca/ca.crt,ca/server.crt,ca/server.key,ca/dh2048.pem,client.crt,client.key.
- Open the
Network Connectionsapplet and make a bridge between your physical NIC (e.g.,Wi-Fi) andOpenVPN TAP-Windows6.
- Install OpenVPN on your WSL2.
- Rename
[win-hostname]inclient.confto your Windows host name and move the file to/etc/openvpn/. - Make a directory
/etc/openvpn/caand copyclient.crtandclient.keyinto this directory. - Rename
[wsl-hostname]in wsl.conf to change your WSL2 hostname from the Windows hostname and move this file to/etc/.
- Start OpenVPN server on your Windows host.
- Reboot your WSL2 by using
wsl.exe --shutdown. - Start WSL2 and execute
start-services.sh. - Now your WSL2 has a network adapter
tap0, and any machines in LAN can access your WSL2 withssh [wsl-hostname].local.
- If the network speed gets extremely slow (e.g., 0.5Mbps), rebooting your machine sometimes resolves this problem.
- Windows firewall configuration to accept only the access from WSL2