Cannot redirect ip traffic with iptables to new ip on linux centOS

Posted by Kiwi on Server Fault See other posts from Server Fault or by Kiwi
Published on 2012-08-28T21:47:35Z Indexed on 2012/09/11 15:40 UTC
Read the original article Hit count: 215

Filed under:

today I able to migrate some of the game servers to another server and needed some help to redirect the traffic from old ip to the new one.

SERVER1 1.1.1.1 ----- (internet ) -----> SERVER 2.2.2.2

I asume to use iptables to perform this, for that used this rule on my centOS box in the server1.

/etc/sysctl.conf: net.ipv4.ip_forward = 1

iptables -t nat -A PREROUTING -p udp --dest 1.1.1.1 --dport 27015 -j DNAT --to-destination 2.2.2.2:27015
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A POSTROUTING -d 2.2.2.2 -p udp --dport 27015 -j SNAT --to 1.1.1.1

But the client cannot connect to the server from the old ip, the redirection don't started.

© Server Fault or respective owner

Related posts about iptables