Last active
April 30, 2023 08:55
-
-
Save SaeedDev94/94a7eedebd534d1c87c92a7a5c412375 to your computer and use it in GitHub Desktop.
TCP/UDP simple port-forward
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FROM="1024" | |
TO="443" | |
DEST="x.x.x.x" | |
# Flush nat rules | |
iptables -t nat --flush | |
# Exclude localhost | |
iptables -t nat -A POSTROUTING ! -s 127.0.0.1 -j MASQUERADE | |
# TCP Port Forward | |
iptables -t nat -A PREROUTING -p tcp --dport "$FROM" -j DNAT --to-destination "$DEST:$TO" | |
# UDP Port Forward | |
iptables -t nat -A PREROUTING -p udp --dport "$FROM" -j DNAT --to-destination "$DEST:$TO" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment