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 to other host

I've used the steps below to temporary redirect traffic during migration to another host. Tested on CentOS 6.x

  • Enable forwarding:
    sysctl net.ipv4.ip_forward=1
  • Forward port:
    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.1428422619.txt.gz · Last modified: 2015/04/07 16:03 by admin