Skip to content

Instantly share code, notes, and snippets.

@gartnera
Last active February 18, 2025 23:25
Show Gist options
  • Save gartnera/31cafc3d0dcdfb5bf0f5a2192e3fbe2c to your computer and use it in GitHub Desktop.
Save gartnera/31cafc3d0dcdfb5bf0f5a2192e3fbe2c to your computer and use it in GitHub Desktop.
systemd service to forward traffic from port 9000 to 9001. Useful for getting around NAT.
[Unit]
Description=Forward TCP from 9000 to 9001 (bidirectional)
After=network.target
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=/usr/bin/socat TCP-LISTEN:9000,reuseaddr,fork TCP:9001
Restart=always
[Install]
WantedBy=multi-user.target
@kr4bat
Copy link

kr4bat commented Feb 18, 2025

I found the second "TCP-LISTEN" and some more stuff confusing and changed it :-)
/usr/bin/socat TCP-LISTEN:40022,fork TCP:127.0.0.1:22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment