1

Imagine a home network of several computers connected via router to an ISP.

Computer A wants to request a webpage from a remote website, 10.234.12.8. The address is not in its ARP cache, so it consults its routing table and finds a match in the form of the default gateway (the router). It sends the packet to the router with the router's MAC. I know that when the router receives the outgoing request, it must do some enveloping and address re-writing, but I don't know the details.

When the response comes back to the router from the 10.234.12.8, how does the router know that the inbound packet should be forwarded to Computer A? In other words, what does the router put in the request to 10.234.12.8 that 10.234.12.8 will include in its response so that the router can determine that the response should go to A? Is it A's MAC address? Or is it A's subnet IP? My guess is the later (A's subnet IP). Is A's LAN address enveloped in the inbound packet? My guess (hope) is that A's MAC address is never seen by anyone on the other side of the router.

I know the router is receiving in-bound web responses all the time and doling them out to the correct local nodes. Is it doing this with enveloped MACs or enveloped LAN IP's, or with some other technique?

4
  • en.wikipedia.org/wiki/Network_address_translation
    – Caraxian
    Commented Oct 2, 2014 at 21:49
  • What confuses me is that, recently, I read that not all consumer-level routers are NAT-capable. I have read in some places that the port remapping is how the router does it; in other places, I have read that the router must remain stateless (which implies to me that all information is encoded in the packets, using the MAC or the IP of the originating computer.) Commented Oct 2, 2014 at 22:08
  • I am not sure where you are reading all that, but it is wrong. Any device performing NAT is stateful, with the exception of the rare one-to-one NAT. I would guess 99.9% of the consumer broadband routers sold in the last 10 years are NAT capable.
    – Zoredache
    Commented Oct 2, 2014 at 22:23

1 Answer 1

1

It works precisely the same way end systems do it. When your browser makes two connections to a web server, the destination IP address and destination port are the same. The system, whether router doing NAT or end node, assigns each connection a distinct local source port address. Replies are distinguished by the destination port address in the reply which corresponds to the source port address in the outbound packets.

Not the answer you're looking for? Browse other questions tagged .