2023-08-25 20:39:55 -07:00
|
|
|
nat () {
|
|
|
|
# All traffic to $THIS_PORT on this container
|
|
|
|
# will be redirected to $THAT_PORT on $THAT_IP
|
2025-01-18 10:46:47 -08:00
|
|
|
THAT_IP=$1
|
2023-08-25 20:39:55 -07:00
|
|
|
THIS_PORT=$2
|
|
|
|
THAT_PORT=$3
|
|
|
|
|
|
|
|
# Accept forward incoming traffic
|
2025-01-18 10:46:47 -08:00
|
|
|
iptables -I FORWARD -d $THAT_IP -m tcp -p tcp --dport $THAT_PORT -j ACCEPT
|
2023-08-25 20:39:55 -07:00
|
|
|
|
|
|
|
# Accept forward return traffic
|
2025-01-18 10:46:47 -08:00
|
|
|
iptables -I FORWARD -s $THAT_IP -m tcp -p tcp --sport $THAT_PORT -j ACCEPT
|
2023-08-25 20:39:55 -07:00
|
|
|
|
|
|
|
# Redirect packets to remote
|
|
|
|
iptables -t nat -I PREROUTING -m tcp -p tcp --dport $THIS_PORT -j DNAT --to-destination $THAT_IP:$THAT_PORT
|
|
|
|
}
|
|
|
|
|
2025-01-18 10:46:47 -08:00
|
|
|
NAT_IP=$(dig +short betalupi.com)
|
2023-08-25 20:39:55 -07:00
|
|
|
nat $NAT_IP 33 10013
|
|
|
|
nat $NAT_IP 993 10015
|
|
|
|
nat $NAT_IP 587 10016
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Include this line ONCE, at the end.
|
2025-01-18 10:46:47 -08:00
|
|
|
iptables -t nat -I POSTROUTING -d $NAT_IP -j MASQUERADE
|