Ben Stienstra

Linux, Unix, network, radio and more...

User Tools

Site Tools


migration_temporary_redirect

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 <num>
      iptables -D FORWARD <num>
migration_temporary_redirect.txt · Last modified: 2015/04/07 16:09 by admin