Created
April 13, 2018 12:48
-
-
Save nyrahul/3ddb0df69f8898ce62d3da16a7a8c3f9 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
#!/bin/bash | |
set -E | |
trap 'echo Failed at $lineno COMMAND: $BASH_COMMAND && exit 1' ERR | |
SRV_IP="192.168.106.2" | |
SP_IP="192.168.105.2" | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
iptables -F | |
iptables -t nat -F | |
iptables -X | |
# Forward UDP packets coming on port 25000 to SERVER-PROXY | |
iptables -t nat -A PREROUTING -p udp -m udp --dport 25000 -i eth0 -j DNAT --to-destination $SP_IP | |
iptables -A FORWARD -d $SP_IP -p udp --dport 25000 -j ACCEPT | |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
# Forward UDP packets coming on port 60000-60099 to SERVER directly | |
iptables -t nat -A PREROUTING -p udp -m udp --dport 60000:60099 -i eth0 -j DNAT --to-destination $SRV_IP | |
iptables -A FORWARD -d $SRV_IP -p udp --dport 60000:60099 -j ACCEPT | |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment