Skip to content

Instantly share code, notes, and snippets.

@goors
Forked from eresende/mysql_forward.sh
Created March 4, 2021 16:47
Show Gist options
  • Save goors/8feca4633da1878a7f108b32f5b513ba to your computer and use it in GitHub Desktop.
Save goors/8feca4633da1878a7f108b32f5b513ba to your computer and use it in GitHub Desktop.
Forward MySQL port to another IP with IPTABLES
iptables -t nat -A PREROUTING -p tcp --dport 3306 -j DNAT --to 10.0.4.172:3306
iptables -A FORWARD -p tcp -d 10.0.4.172 --dport 3306 -j ACCEPT
iptables -t nat -A POSTROUTING -j MASQUERADE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment