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

I'm trying to figure out how packets work on a network to better understand networking. I've read a few introductions so far.

I'm trying to understand what happens to a packet when it passes through a router. Is the Source Host changed to the Router IP before it gets forwarded on to the next hop? Is there anything else that changes in the packet?

share|improve this question

Per default, the IP source stays the same from source till target. Otherwise, the target would now know how (where) to reply.

"A packet" of information consist of several layers of protocols.
The typical jobs of a router are (in this order):

  • strip the outer physical and link layers of "a packet"
  • examine the network layer information
  • determine which NIF is associated with the IP address of "the packet"
  • modify (or re-apply) link and physical layer info so it fits the next hop
  • send the packet forward.
share|improve this answer
    
You should have asked first if it's a NAT router or not))) Because in case of a NAT router the source IP is actually changing to a router's "external" interface' IP (Masquerading) – Drew Mar 17 at 6:01
    
In a home router, NAT may be default. That is not apparent in the question. – Ярослав Рахматуллин Mar 17 at 6:10
    
It's obvious. OP wants to understand in which cases the source IP could change when packet is passing through router and NAT is one of possible options and the likely one… – Drew Mar 19 at 4:55
    
I guess you are right, the answer is not addressing the second part of the question. – Ярослав Рахматуллин Mar 19 at 5:31

Routers forward packets between subnets.

Forwarding means accepting a packet from one interface, and shipping out the same exact packet from a different interface. Both interfaces must be within different subnets. Corollary: a router by definition has two network interfaces.

In the plain vanilla case nothing changes in the packet except the TTL (ipv4) or Hop Limit (ipv6) is decremented, and the router tosses the packet if 0.

Obviously the router is well positioned for a packet filter, firewall, etc. to modify outgoing or incoming traffic but such functions are not forwarding/routing per se.

The source IP is not changed unless network address translation is being used, as is the case with most consumer and many business network routers. With NAT, the source IP becomes the router's IP, and router needs to remember that anything coming back from that packet's destination address is really meant for the original system that sent it.

share|improve this answer

In general the source IP address doesn't change, only the data link layer addresses change (e.g. the source MAC address). However there are some situations when the source IP address is "changed" and those are:

In all of the above the IP address (source, destination or both) are physically changed, but the router tracks the connection and changes the pre-changed IP address back when the traffic comes back into the traffic source.

share|improve this answer

Your Answer

 
discard

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.