{{tag>[iptables networking linux]}}
=====Temporary redirect traffic to other host=====
I've used the steps below to temporary redirect IP traffic, during migration to another host. Tested on CentOS 6.x
* Configure the kernel to allow forwarding:echo 1 > /proc/sys/net/ipv4/ip_forward
* Route traffic to destination:iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 2.2.2.2:443
* Allow forwarding: iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -p tcp -d 2.2.2.2 --dport 443 -j ACCEPT
* Masquerade outgoing connections:iptables -t nat -A POSTROUTING -j MASQUERADE
* Show active rules:iptables -nvL -t nat
* Delete rules:
* Find line numbers: iptables -nvL -t nat --line-numbers
* Delete rules using line number:iptables -t nat -D
iptables -D FORWARD