Skip to content

Instantly share code, notes, and snippets.

@suuhm
Created February 20, 2024 08:29
Show Gist options
  • Save suuhm/9bc2e726d970bd9783e2c1394d98cdb5 to your computer and use it in GitHub Desktop.
Save suuhm/9bc2e726d970bd9783e2c1394d98cdb5 to your computer and use it in GitHub Desktop.
Windows Setup Portforwarding 4to4 Proxy Tunnel
@echo off
SETLOCAL ENABLEEXTENSIONS
REM 424_tunnel script (c) 2024 suuhm
REM netsh interface ipv4 set interface "Ethernet" forwarding=enabled
REM netsh interface portproxy add v4tov4 listenaddress=lokal_IP listenport=9999 connectaddress=target_IP connectport=80
REM netsh interface portproxy show all
:: The name of the network interface
set INTERFACE_NAME=Ethernet
:: The local IP address to listen on (0.0.0.0 for all addresses)
set LISTEN_ADDRESS=0.0.0.0
:: The port your computer will listen on
set LISTEN_PORT=9999
:: The target IP address to forward the traffic to
set CONNECT_ADDRESS=target_IP
:: The target port on the target computer
set CONNECT_PORT=80
:: Enable IP forwarding for the chosen interface
netsh interface ipv4 set interface "%INTERFACE_NAME%" forwarding=enabled
:: Add the port forwarding rule
netsh interface portproxy add v4tov4 listenaddress=%LISTEN_ADDRESS% listenport=%LISTEN_PORT% connectaddress=%CONNECT_ADDRESS% connectport=%CONNECT_PORT%
echo Port forwarding rule added.
echo Interface: %INTERFACE_NAME%
echo Listening on: %LISTEN_ADDRESS%:%LISTEN_PORT%
echo Connecting to: %CONNECT_ADDRESS%:%CONNECT_PORT%
:: Wait for user input to not close the window immediately
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment