Skip to content

Usefully script to forward WSL2 distro ports despite IP changing after each reboot

Notifications You must be signed in to change notification settings

Suniron/wsl-port-forwarding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

wsl-port-forwarding

This script can be used to handle the forwarding of ports between your Windows host and your WSL2 machine.

This is usefully because WSL2 distros cannot have a fixed IP address so binding port after each reboot of them is necessary.

Prerequisites

  • Python3 installed on Windows host.
  • net-tools installed on WSL (sudo apt install net-tools).

Usage

  1. Launch a terminal (bash or cmd) as Administrator.
  2. Clone the script on your Windows machine.
  3. Get the name of the WSL distribution (wsl.exe -l).
  4. In python script, fill the PORTS_TO_FORWARD variable with all ports you want to forward.
  5. Run the script: python3 wsl-auto-forwarding.py "Name of you WSL machine".

About

Usefully script to forward WSL2 distro ports despite IP changing after each reboot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages