Cross-platform TCP/UDP port forwarder with saved configurations, traffic statistics, access control, rate limiting, and optional TLS termination.
Forward local ports to remote destinations without SSH -- as a single static binary.
Download the latest release for your platform from the releases page.
go install github.com/jmsperu/portfwd@latestgit clone https://github.com/jmsperu/portfwd.git
cd portfwd
make build# Forward TCP port 8080 to a remote host
portfwd 8080:remote.host:80
# Forward UDP port
portfwd -u 5060:sip.server:5060
# Save, start, and manage forwards
portfwd add web 8080:remote.host:80
portfwd up web
portfwd statsportfwd <local_port:remote_host:remote_port>Starts an ad-hoc forward immediately. Press Ctrl+C to stop.
| Flag | Description |
|---|---|
-u, --udp |
Use UDP instead of TCP |
--tls-cert |
TLS certificate file for TLS termination |
--tls-key |
TLS key file for TLS termination |
--allow |
Allowed source CIDRs (comma-separated) |
--deny |
Denied source CIDRs (comma-separated) |
--rate-limit |
Rate limit in bytes/sec per connection (0 = unlimited) |
Save a named forward configuration for later use.
portfwd add web 8080:remote.host:80
portfwd add sip 5060:sip.server:5060 -u
portfwd add secure 443:backend:8443 --tls-cert cert.pem --tls-key key.pem
portfwd add restricted 8080:internal:80 --allow 10.0.0.0/8 --deny 192.168.1.0/24List all saved port forwards in a table.
portfwd list
portfwd lsStart one or more saved forwards.
portfwd up web # start a single forward
portfwd up web sip # start multiple forwards
portfwd up --all # start all saved forwards| Flag | Description |
|---|---|
-a, --all |
Start all saved forwards |
Remove a saved forward by name.
portfwd remove web
portfwd rm webShow traffic statistics for recent forwarding sessions.
portfwd statsDisplays connections, bytes in/out, and last active time for each forward.
Saved forwards are stored in ~/.portfwd.yml:
forwards:
web:
protocol: tcp
listen_port: 8080
remote_host: remote.host
remote_port: 80
sip:
protocol: udp
listen_port: 5060
remote_host: sip.server
remote_port: 5060
rate_limit: 1048576
secure:
protocol: tcp
listen_port: 443
remote_host: backend
remote_port: 8443
tls_cert: /path/to/cert.pem
tls_key: /path/to/key.pem
allow_cidrs:
- 10.0.0.0/8
deny_cidrs:
- 192.168.1.0/24MIT