Skip to content

yoshipon/wsl-openvpn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenVPN configuration for WSl2

Configuration files that expose WSL2 to LAN.

Note: Please Use Test/Experimental Purpose Only

@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 :)

Quick Summary

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 host
  • conf/client.conf: a configuration file for an OpenVPN client on WSL2
  • conf/wsl.conf: a configuration file for WSL to rename the hostname of WSL2
  • bin/start-services.sh: a script file to start network services and obtain an IP address from a DHCP server

Getting Started

Configuration of Windows

  1. Install OpenVPN on Windows host
  2. Put server.ovpn on the configuration directory of OpenVPN (which may be found in your Start menu).
  3. Make a directory ca on 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.
  4. Open the Network Connections applet and make a bridge between your physical NIC (e.g., Wi-Fi) and OpenVPN TAP-Windows6.

Configuration of WSl2

  1. Install OpenVPN on your WSL2.
  2. Rename [win-hostname] in client.conf to your Windows host name and move the file to /etc/openvpn/.
  3. Make a directory /etc/openvpn/ca and copy client.crt and client.key into this directory.
  4. Rename [wsl-hostname] in wsl.conf to change your WSL2 hostname from the Windows hostname and move this file to /etc/.

Starting VPN

  1. Start OpenVPN server on your Windows host.
  2. Reboot your WSL2 by using wsl.exe --shutdown.
  3. Start WSL2 and execute start-services.sh.
  4. Now your WSL2 has a network adapter tap0, and any machines in LAN can access your WSL2 with ssh [wsl-hostname].local.

Tips

  • If the network speed gets extremely slow (e.g., 0.5Mbps), rebooting your machine sometimes resolves this problem.

Known Issues/To Do

  • Windows firewall configuration to accept only the access from WSL2

About

OpenVPN configuration for WSL2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages