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?


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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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