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

I am trying to divert a TCP connection. Given a client (C) which is connected to a router R and two servers (S1 and S2) are connected to the router, C initially connects to S1. I am trying to write an iptables rule in the router to divert all traffic to S2. But the problem is, S2 keeps on sending RST messages and the connection is never established. I ran wireshark on all the boxes and noticed this: C sets up a TCP connection with S1 and when my iptable rule starts is active, it sends an ACK to S2 which sends back a RST and then they loop on this for time. Is there a way to divert TCP connections like this?

share|improve this question

migrated from Jul 29 '12 at 19:01

This question came from our site for professional and enthusiast programmers.

You want to divert a connection that is in progress? It's damn hard. Diverting a connection before it is established however is trivial. – anttix Jul 28 '12 at 2:16
Yes, I am looking for ways to divert while it is in progress. – Abhishek Chanda Jul 28 '12 at 2:31
This is almost impossible to do. TCP protocol has Sequence numbers that are generated randomly at the start of each connection and can not be re-used. The only way to "divert" it is to close the connection and force client to re-connect. – anttix Jul 28 '12 at 2:41
But what is the motive of doing all this. May I know what u are tying to do .. – pradeepchhetri Jul 29 '12 at 19:49

Your Answer


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

Browse other questions tagged or ask your own question.