Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 try to telnet from PC 3 To PC 1 and it's redirect to PC 2

PC 1 :

PC 2 :

PC 3 :

i have command like this in PC 1:

  1. iptables -t nat -A PREROUTING -p tcp -d --dport 23 -j DNAT --to-destination

  2. iptables -t nat -A POSTROUTING -j MASQUARADE

If I just do command number 1, In PC 2 shows(log file) that the telnet is a PC 3(is success) but it's can not telnet(can't telnet) just only send the connection. But when i combined with command number 2, telnet can be done(telnet success) but in file log(in PC 2) shows that ip who telnet is PC 1, but actually that does telnet is PC 3.

How i resolve that?

share|improve this question

In case when you have first command configured, the connection that comes to PC1 will be redirected to PC2 and PC2 sees the connection as originating from PC3 (since PC1 has only changed destination and not source). Now PC2 responds to connection (SYN) and sends back a SYN,ACK to PC3. but PC3 will drop it (Reason PC3 opened a telnet connection to therefore its expecting response from that IP, but since the connection was redirected source IP would be that of PC2)

In second case since you have Masqueraded the source IP to that of PC1 , PC2 will see PC1 as source of all the connections.

What you need to do is change the source IP address of outgoing packets on PC2 to on PC2.

(Note:Do not use the second command i.e. MASQUERADE on PC1)

Configure this on PC2

iptables -A POSTROUTING -t nat -p tcp --sport 23 -d -j SNAT --to-source
share|improve this answer

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.