Does TCP care about the incoming port?

1

Does TCP care if the port changes on a SYN/ACK that comes back compared to the destination port asked for?

I.E. If i have a port forward turning 80 into 8080, and the client sends a SYN on 80 and gets a SYN/ACK from server:8080 will it drop that packet?

Derek

Posted 2012-11-07T02:14:04.837

Reputation: 605

Answers

1

The answer is yes. If the SYN/ACK reply to a SYN packet to port 80 comes back from port 8080 (instead of from the expected port 80), then TCP will drop the reply packet. The reason is that if the source port in the SYN/ACK does not match the original destination port of the SYN, then as far as TCP is concerned, the incoming SYN/ACK packet is not related to the original SYN packet it sent out.

When a client's connection to a server is DNAT-ed from port 80 to 8080 by a router, all replies to that client will have the reverse transformation done to them by the router. That is, the source port on all replies will be transformed from 8080 to 80. Thus, to the client, it looks like the server is actually listening on port 80.

Steven Monday

Posted 2012-11-07T02:14:04.837

Reputation: 1 445

0

That port forwarding rule will automatically change the responding source port to port 80. The client will never know port 8080 exist.

John Siu

Posted 2012-11-07T02:14:04.837

Reputation: 4 957