0

When we send e.g. HTTP request to server A, how can it know where to send the response? While routing, a packet goes through multiple routers - and every router transfers it to the next router with own IP as source. So the source IP (of original request initiator) is lost.

I guess my above understading is wrong, but what's wrong there?

Maybe packets from network layer are nested? I mean that the original IP packet is a data field in packet that transfers packet to the next router?

How it works?

Szyszka947
  • 125
  • 3

1 Answers1

3

A router does not transfer IP packets with its own IP address as source. It keeps the original source IP address, so it is not lost.

A corner case is routers with network address translation (NAT). They do indeed replace the original source IP address with their own. They have to register a bidirectional mapping (original source IP address, original source port) <-> (rewritten source IP address, rewritten source port) so they can rewrite response packets and subsequent packets.

  • How it keeps the original source IP address? The IP packet can be created "freely"? If yes, it means that everyone can easily spoof source IP address? – Szyszka947 May 14 '23 at 20:10
  • 2
    Yes, but not if one wanted to get back the response ... – harrymc May 14 '23 at 20:24