Skip to content

Instantly share code, notes, and snippets.

@JSH32
Created July 1, 2024 18:49
Show Gist options
  • Save JSH32/d6ebb2306f08544602115921a4a56095 to your computer and use it in GitHub Desktop.
Save JSH32/d6ebb2306f08544602115921a4a56095 to your computer and use it in GitHub Desktop.
Port forward out of a tunneled server
# /etc/ufw/before.rules
*nat
:PREROUTING ACCEPT [0:0]
# Port forward example
-A PREROUTING -p tcp --dport 443 -j DNAT --to ip:443
-A PREROUTING -p tcp --dport 80 -j DNAT --to ip:80
# setup routing
-A POSTROUTING -j MASQUERADE
COMMIT
@JSH32
Copy link
Author

JSH32 commented Jul 1, 2024

This is usually done in combination with tailscale to expose a server that cant port forward directly from a different location

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