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
  • 3
    Does this answer your question? [How does a web server return an HTTP request?](https://superuser.com/questions/833325/how-does-a-web-server-return-an-http-request) – Destroy666 May 14 '23 at 19:42
  • @Destroy666 I think it doesn't. That one is as it relates to NAT (device behind a router), his question is in general on the internet how it comes back to his public IP. – Yisroel Tech May 14 '23 at 19:48
  • Maybe this one [What happens to a network packet originating from my IP as it travels through the Intenet?](https://superuser.com/a/849538/368970) – Yisroel Tech May 14 '23 at 19:52

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.

user2233709
  • 558
  • 3
  • 16
  • 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