Created
July 8, 2020 07:21
-
-
Save Eronana/e85e60148d55d6c8c6aea98e7ed0e984 to your computer and use it in GitHub Desktop.
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
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf | |
INTERFACE=eth0 | |
PROTOCOL=tcp | |
LOCAL_PORT=8080 | |
REMOTE_HOST=www.baidu.com | |
REMOTE_PORT=80 | |
echo "forward $PROTOCOL `ip -4 -o addr show $INTERFACE | awk '{print $4}' | cut -d "/" -f 1`:$LOCAL_PORT to $REMOTE_HOST:$REMOTE_PORT" | |
iptables -t nat -A PREROUTING -p $PROTOCOL -i $INTERFACE --dport $LOCAL_PORT -j DNAT --to $REMOTE_HOST:$REMOTE_PORT | |
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