fundamental networking question (NAT)

serpretetsky

2[H]4U
Joined
Dec 24, 2008
Messages
2,180
I'm trying to figure out how NAT tables work and how a router knows which computer to send an income packet to.

So let's say i have two machines on my network both connecting through the router to http://hardforum.com.

I'm assuming the original Private IP's are completely stripped off by the router, correct? So my http get packet goes out from both machines, one is asking for image1, the other is image 2. The 192.168.100.67 and 192.168.100.68 are stripped from my packets, and instead, both are replaced with my internet ip yy.yy.yy.yy. Am i correct so far?

How will my router know that image1 coming back from http://hardforum.com is for 192.168.100.67 and that image2 coming back is for 192.168.100.68.

Does it inject some sort of signature into the outgoing packets that are then included in the incoming packets?
 
it changes the port numbers and keeps track of which IP it gave that port number to.
 
The packet's destination IP address will never change, however the source address will, it will start with the computers private network IP address the packet will go to the router with the private address it will check if the destination is in it's routing table and if it can find it then it will save the computers private address to a different table then replace the source address with the router's first available public IP address, and then the two ips will be "linked" then the router will forward the packet. (this is my understanding of dynamic NAT)
 
it changes the port numbers and keeps track of which IP it gave that port number to.
ahh, i forgot about ports. so in that case my 192.168.100.67:80 will be converted to yy.yy.yy.yy:a while 192.168.100.68:80 will be converted to yy.yy.yy.yy:b on the outgoing packets?

If that is the case, though, how does my router know where to send ICMP packets which are portless.

The packet's destination IP address will never change, however the source address will, it will start with the computers private network IP address the packet will go to the router with the private address it will check if the destination is in it's routing table and if it can find it then it will save the computers private address to a different table then replace the source address with the router's first available public IP address, and then the two ips will be "linked" then the router will forward the packet.
sorry, I found this confusing. The router will check it's routing table for the destination IP? Why would the router have the destination IP in it's table before it's even recieved the packet with the destination ip?
 
ahh, i forgot about ports. so in that case my 192.168.100.67:80 will be converted to yy.yy.yy.yy:a while 192.168.100.68:80 will be converted to yy.yy.yy.yy:b on the outgoing packets?

If that is the case, though, how does my router know where to send ICMP packets which are portless.

I don't think anything is portless other than WAN protocols? ICMP just rides inside an IP packet.
 
I don't think anything is portless other than WAN protocols? ICMP just rides inside an IP packet.
Hmm... i didn't realize ICMP is part of the network layer and not the transport layer. So then, at what point does my ICMP "ping" request get encapsulated within a IP packet. Before it even leaves my network card?

If that's the case, what port do "ping" commands usually sit on?
 
Hmm... i didn't realize ICMP is part of the network layer and not the transport layer. So then, at what point does my ICMP "ping" request get encapsulated within a IP packet. Before it even leaves my network card?

If that's the case, what port do "ping" commands usually sit on?

They don't use any port. ICMP is seperate from TCP and UDP (TCP and UDP being the layer 4 protocols that have ports assigned to them).
 
Back
Top