Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let' say we have two instances of webserver listening on port 80 and 81 and I want to seamlessly redirect customer traffic without losing any packets from instance1 to instance2.
My understanding that simple NEW match would work.Is it correct?

$ iptables -A PREROUTING -t nat -p tcp --dport 80 -m state --state NEW -j REDIRECT --to-port 81

I expect old connection to be open until they are closed and any new connections would be redirected to the new port.

share|improve this question
up vote 1 down vote accepted

Don't forget to also allow input on the port you're redirecting to.

--iptables -A INPUT -p tcp --dport 81 -j ACCEPT
share|improve this answer
Thank you Peter, my assumption was that no other rules are in place – Sergei Sep 22 '11 at 8:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.