Coder Social home page Coder Social logo

j0n3 / wsl2portmappingtool Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 14 KB

Manage firewall rules and port forwardings to expose a port from your WSL2 machine

Batchfile 100.00%
batch-script firewall firewall-management firewall-rules windows windows-10 windows-tools wsl wsl2 wsl2-forwarding-port

wsl2portmappingtool's Introduction

WSL2PortMappingTool [Work In progress]

Manage Windows firewall rules and port forwardings to expose a port in your WSL2 machine.

Tested in Windows 10

Firewall Rules and Port Forwardings for WSL2
--------------------------------------------------
Firewall Rule: Allowing LAN connections to port 5000
    0.0.0.0:5000 to localhost:5000


1) Create new rule and port forwarding
2) Delete an existing rule
3) Display Firewall Rule for port
4) Display all Firewall rules "Allowing LAN connections to port *"
5) Display all port forwardings
0) Exit

Choose an option:

Other useful commands

To add or remove rules administrative privileges are required. Adding or deleting rules persist over reboots and can imply a security risk or cause applications to stop working. Use this at your own risk.

Firewall

All rules backup export

netsh advfirewall export "firewall_rules_backup.wfw"

Import backup

netsh advfirewall import "firewall_rules_backup.wfw"

Show all firewall rules

netsh advfirewall firewall show rule name=all

Show all rules matching a pattern

netsh advfirewall firewall show rule name=all | find "Allowing LAN connections to port"

Show config for a single rule

netsh advfirewall firewall show rule name="Allowing LAN connections to port 5000"

Add an in rule open for everyone

netsh advfirewall firewall add rule name="Allowing LAN connections to port 5000" dir=in action=allow protocol=TCP localport=5000

Add an in rule for a single ip

netsh advfirewall firewall add rule name="Allowing LAN connections to port 5000" dir=in action=allow protocol=TCP localport=5000 remoteip=192.168.1.83/32

Delete a rule

netsh advfirewall firewall delete rule name="Allowing LAN connections to port 5000"

Port forwarding

Show all forwardings

netsh interface portproxy show all

Add forwarding

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=5000 connectaddress=localhost connectport=5000

Delete forwarding

netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=5000

Credits

Thanks to ChatGPT :)

wsl2portmappingtool's People

Contributors

j0n3 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.