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

HTTP servers usually operate at port 80. Yet NAT routers as most are these days assign port to outgoing requests so they would know when request is returned that which computer connected to it, it's suppose to be. They do it cause they can only use one public IP even though all computers behind router are given public IP address they are local IP address. Meaning they only work for everyone behind that router.

So how does server handles this. It only works at port 80, and router sends at whatever ports it wishes to do based on what is available and how it is programmed.

My understanding:

  1. Computer A to router.

  2. Router to World: -ISP given IP address:Port to distinguish between computers connected to it.

Now what

Or maybe there is a difference between port and source port.

share|improve this question
up vote 1 down vote accepted

You're confusing source ports and destination ports. When the request is sent to the HTTP server, the destination port is 80 since that's what web servers typically listen on. NAT routers can choose whatever source port they want. When they receive replies, they use the destination port (and other information), which should match the source port they choose for the outbound packets, to know which connection the packets are associated with.

Your computer has to do the same thing. Say you fire up two different browsers and you point each at How do you think your computer tells which TCP connection incoming packets belong to?

share|improve this answer
So you are saying that even though server listens at port 80, and that is what the destination port would be for request made by a computer/router, The server can send back data at different ports..or in other words server only listens at port 80 but reply at all ports. – Muhammad Umer Mar 5 '13 at 5:10
The server replies to whatever requests it gets. When it forms a reply, it sets the destination port of its reply equal to the source port of the request. The source port of its replies is 80. – David Schwartz Mar 5 '13 at 5:11

The server always receives the data on port 80 - the router does not rewrite the port, only the source address - at least in the "typical" case.

The truth is the server does NOT know which machine behind the NAT router is requesting the traffic initially, but there are a few things it can do to find out -

  1. It can look at information the browser sends to the server as part of the request, and use things like the REFERER (referrer) field to see the last page the browser visited and the browser identification string. (There are no doubt others, it is possible to "fingerprint" a client reasonably uniquely if you are desperate)

  2. The first time the browser visits the site (or logs in or whatever), cookies can (and generally are) used by the server to track the browsers movement through the site. These cookies can be used to differentiate machines / sessions.

share|improve this answer
what is REFERER? I wanna know. – Muhammad Umer Mar 5 '13 at 5:05
LMGTFU - (In a nutshell the browser tells the server the last page you visited using a "Referer" field in the header of an HTML request. "REFERER" is actually the correct spelling for the field - it was a typo in the original specification document which has manifested. If you use PHP you can generally get this information through the variable $_SERVER['HTTP_REFERER'] – davidgo Mar 5 '13 at 5:11
lol i didn't mean to call out spelling or anything. I want to know more about this. Thanks Man. – Muhammad Umer Mar 5 '13 at 5:21

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.