Does a TCP packet change source ip when it goes through your router?

Click For Summary
When sending or receiving TCP packets, the local IP address (e.g., 192.168.1.x) is displayed as the source or destination. This address is altered by the router, which functions as a Network Address Translation (NAT) unit. NAT changes internal IP addresses to an external IP address for communication with the internet, allowing multiple devices to share a single external IP. The router can either assign external IPs to connected devices or maintain internal local IPs, depending on its configuration. In cases where a modem assigns external IPs, it acts as a bridge and does not modify packet IP information. Additionally, if a cable modem is disconnected from its service, it assigns local IPs, allowing the home network to operate as a LAN. The behavior of DSL modems in similar situations is less certain.
saminator910
Messages
95
Reaction score
2
I was wondering, every time I send or receive a TCP packet with an IP header, my local ip, ie. 192.168.1.x is displayed as the source or destination, respectively. Does this get changed as soon as the packet passes through my router, so the source/destination is listed as my external IP address?
 
Technology news on Phys.org
Small correction: Your external IP address is on the body, never on the header. IPs on the header are to communicate between local applications. Whether that header IP gets dropped in the computer or on the router, I don't know (which is basically what you asked). :( Maybe someone could provide some more insight.
 
Your "router" is not just a "router" in the original meaning of the word. It is also a "network address translation" (NAT) unit.

Pure routers do not change IP addresses. They just pass the IP packet to whatever physical network is likely to transport it to its destination.

NATs do change addresses. That is why they exist. They map multiple "internal network addresses" to a single (sometimes also multiple) "external network address".
 
This depends on how your modem router function is configured. Typically the devices connected to a modem get an internal local IP and the router funcion of the modem converts these to an external IP with port numbers that vary depending on the local IP's so that it knows which external packets belong to which internal local IP. The alternative is the router function of the modem assigns an external IP to the devices connected to the modem, essentially converting the in home lan into an extension of the internet. From what I've read, all cable modems can do this for at least 16 external ips, but the internet service providers limit this, for example my ISP only allows 3 external ips for a home account. The home dsl modems that do this typically provide 8 static external ip's but use 3 of these, allowing up to 5 connected devices to have independent external ip's. Note that one or more of those connected devices could be standard routers, which would be assigned external ip's and in turn assign local ip's to the devices connnected to the router.

Getting back to the original question, if the modem assigns external ips to devices connected to the modem, then the modem acts like a bridge and does not change packet ip information.

Side note, in the case of a cable modem, if it's disconnected from the coax cable (or the cable service isn't working), it then assigns local ip's, and the home network will behave as a lan. I don't know if a dsl modem does the same thing if disconnected from the phone line.
 
Last edited:
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 14 ·
Replies
14
Views
2K
Replies
9
Views
5K
Replies
8
Views
12K
  • · Replies 152 ·
6
Replies
152
Views
10K
Replies
23
Views
4K
Replies
3
Views
5K
  • · Replies 29 ·
Replies
29
Views
6K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K