Created
December 5, 2022 13:46
-
-
Save blackestwhite/6797d35d39c6368f4813bd47e65cd2b6 to your computer and use it in GitHub Desktop.
port forwarding using ip tables
This file contains hidden or 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 | |
read -p "Enter your proxy server's IP: " PROXY_IP | |
read -p "Enter your destination server's IP: " DEST_IP | |
sysctl net.ipv4.ip_forward=1 | |
iptables -t nat -A PREROUTING -p tcp --dport 22 -j DNAT --to-destination $PROXY_IP | |
iptables -t nat -A PREROUTING -j DNAT --to-destination $DEST_IP | |
iptables -t nat -A POSTROUTING -j MASQUERADE | |
iptables-save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment