2

I am new to networks and had some quick lessons from Tannenbaum.

I was playing with my router and found out that the router assigns my devices an IP address in the range of 192.168.178.x. However, the public IP address is something different which I could find out over www.whatismyip.com.

The question is how does the router know which device (laptop 1 or laptop 2) has sent the query to an external server because the external server replies just with my public IP address, and the router has to route the response to the device which sent the request.

I read about NAT (Network Address Translation), but I could not find any reference to it in the Manual of my router. Is it really NAT that is doing the look up table for the IP addresses, or is there some other software running in the router that prepares the lookup table, i.e does the translation?

6
  • 1
    Unfortunately, questions about consumer-grade devices are explicitly off-topic here. You could try to ask this question on Super User.
    – Ron Maupin
    Mar 10, 2017 at 12:39
  • But I wanted to know generally about routers not specific to Fritzbox. Fritzbox is just an example here. Mar 10, 2017 at 14:29
  • Then you should edit your question to not ask about the "Working of a Fritzbox or DSL router," and specifically ask about NAT.
    – Ron Maupin
    Mar 10, 2017 at 14:34
  • do you mean you actually get courses with THE Andrew Tannenbaum?
    – JFL
    Mar 10, 2017 at 15:24
  • @JFL, no, the book. sorry for my language deficiency. Mar 10, 2017 at 17:18

1 Answer 1

1

NAT (Network Address Translation) is a method created to extend the life of IPv4. Without it, we would have completely run out of IPv4 addresses many years ago, instead of more recently, as has happened. Unfortunately, NAT breaks the IP model of end-to-end connectivity, where each device has a unique IP address.

NAT, at it core, simply translates either or both the source and destination addresses on IP packets to be different addresses. There are multiple variations of NAT. The common version used to allow devices on a network with private addresses use a single public address is call NAPT (Network Address Port Translation).

NAT can be used on different device types, but it is most convenient to to run a NAT process on a firewall or router that connects a private network to the public Internet. It is not a firewall or router requirement to run NAT, but that is usually the logical place to run it.

NAPT looks at the source layer-3 and layer-4 addresses of packets passing from inside to outside, then it creates or updates an entry in a NAT table and replaces the source layer-3 and layer-4 addresses with different addresses before forwarding the packets.

When a packet comes in from the outside with the layer-3 destination address of the NAT device, NAPT looks at the destination layer-3 and layer-4 addresses, and it looks up in the NAT table to determine which layer-3 and layer-4 address to use to replace the destination addresses, then it replaces those addresses and forwards the packets to the inside. NAT drops any packets for which there are NAT table entries.

NAT table entries will time out, or, in some cases with TCP, will be purged when the connection ends.

It important to NAPT to inspect both the source and destination addresses to create NAT table entries for a particular conversation. That helps to prevent outside hosts that are not part of the conversation from sending unwanted packets to the inside host.

Both the source and destination addresses on the packets must match the NAT table entries before packets are allowed from outside to inside. That means that only inside hosts can initiate a conversation because there is no NAT table entry in place for an outside host to initiate a conversation. This brings up the concept of port forwarding, which essentially create a permanent NAT table entry in order to allow outside hosts to initiate a conversation with an inside host.


For more information about NAT, you can look at RFC 3022, Traditional IP Network Address Translator (Traditional NAT).

8
  • So, can I assume, that all the DSL Home routers, run this protocol? Is there any alternative algorithm? Mar 10, 2017 at 17:17
  • 1
    Unfortunately, questions about home networking and consumer-grade equipment are explicitly off-topic here. You could ask that on Super User.
    – Ron Maupin
    Mar 10, 2017 at 17:21
  • Oh you are write. I have got an answer on SuperUser: superuser.com/questions/715939/…. Poor fellow got 3 downvotes ! What a pity. Mar 10, 2017 at 17:23
  • It looks like the down votes are because it is a duplicate question.
    – Ron Maupin
    Mar 10, 2017 at 17:24
  • 2
    This can be a rough neighborhood if the question is the result of the OP not doing their due diligence research first. Even so, welcome. In time I'm sure you will figure out how this all works. Be sure to take the tour at each of the stackexchange subsites you join.
    – SDsolar
    Mar 11, 2017 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.