I was tired of complicated netsh,iptables,socat commands, so I wrote this simple TCP tunnel application in Go.
This TCP tunnel application allows you to forward TCP connections from one port to another. It can be useful for debugging or accessing services that are not directly exposed or proxy between two networks.
The application has no external dependencies.
It supports both IPv4 and IPv6 connections.
To run the application as standalone:
./gotunnel -listen <source-address>:<source-port> -connect <target-address>:<target-port>-listen <source-address>:<source-port>: The address and port to listen for incoming connections.-connect <target-address>:<target-port>: The address and port to connect to for forwarding the traffic.-help: Show the help message with usage instructions.
if source-address or target-address is not specified, it defaults to all interfaces.
To forward traffic from port 8080 on all interfaces to port 80 on example.com, you can run:
./gotunnel -listen :8080 -connect example.com:80Example of a systemd service file to run the application as a service (gotunnel.service):
[Unit]
Description=Simple TCP Tunnel Service
After=network.target
[Service]
ExecStart=/path/to/gotunnel -listen <source-address>:<source-port> -connect <target-address>:<target-port>
Restart=always
[Install]
WantedBy=multi-user.target
Place the gotunnel.service file in /etc/systemd/system/ and enable it with:
sudo systemctl enable gotunnel.service
sudo systemctl start gotunnel.service