28 lines
739 B
Bash
28 lines
739 B
Bash
nat () {
|
|
# All traffic to $THIS_PORT on this container
|
|
# will be redirected to $THAT_PORT on $THAT_IP
|
|
THAT_IP=$1
|
|
THIS_PORT=$2
|
|
THAT_PORT=$3
|
|
|
|
# Accept forward incoming traffic
|
|
iptables -I FORWARD -d $THAT_IP -m tcp -p tcp --dport $THAT_PORT -j ACCEPT
|
|
|
|
# Accept forward return traffic
|
|
iptables -I FORWARD -s $THAT_IP -m tcp -p tcp --sport $THAT_PORT -j ACCEPT
|
|
|
|
# Redirect packets to remote
|
|
iptables -t nat -I PREROUTING -m tcp -p tcp --dport $THIS_PORT -j DNAT --to-destination $THAT_IP:$THAT_PORT
|
|
}
|
|
|
|
NAT_IP=$(dig +short betalupi.com)
|
|
nat $NAT_IP 33 10013
|
|
nat $NAT_IP 993 10015
|
|
nat $NAT_IP 587 10016
|
|
|
|
|
|
|
|
|
|
|
|
# Include this line ONCE, at the end.
|
|
iptables -t nat -I POSTROUTING -d $NAT_IP -j MASQUERADE |