Kernel NAT port forwarder with expiring rules and SQLite state.
Documentation: see docs/USAGE.md.
Running portfwd with no arguments opens the TUI.
go build -o portfwd ./cmd/portfwdsudo ./portfwd add \
--listen 0.0.0.0:2222 \
--to 10.0.0.5:22 \
--proto tcp \
--source 1.2.3.4/32 \
--expires 12h \
--publicList and inspect:
sudo ./portfwd list
sudo ./portfwd show <id>Delete:
sudo ./portfwd delete <id>TUI:
sudo ./portfwd tuiCleanup expired:
sudo ./portfwd cleanup --quiet- Requires root for iptables and
sysctl net.ipv4.ip_forward=1. - Defaults to
127.0.0.1/32source if you do not pass--sourceand you are not using--public. --publicis required if the listen IP is0.0.0.0or::and requires explicit--sourceor--allow.- State is stored in
/var/lib/portfwd/portfwd.db(override with--dbfor testing).
Use export-iptables to generate a restore file:
sudo ./portfwd export-iptables > /etc/portfwd/rules.v4Then install the systemd unit from dist/systemd/portfwd-restore.service.
Systemd timer files are in dist/systemd/. Cron example is in dist/cron/portfwd.