Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


migration_temporary_redirect

This is an old revision of the document!


~~TOC~~

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 connection:
    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.1428422816.txt.gz · Last modified: 2015/04/07 16:06 by admin