Idan Ofek
Idan Ofek

Reputation: 87

NAT and LAN networking

I've got a little bit confused with LAN networking, so I hope that someone can answer me for few theoretical questions:

Let's assume that I have a little LAN in my home. I'm writing a simple program that will send a 'Hello world' string to a IP that is given by the user. Now, the user is able to send either to the world-wide network, or to the LAN members. My question is:

  1. Behind the scenes, where and by who, the seperation between the packets destinated to the outside world and to the LAN is made?

  2. NAT: we are still working with the program. A user just sent a packet to the outside world, which handled by the router with NAT routing technique. While the packet was in it way to the destination, the NAT table in the router resets. What will happen once the reply packet from the destination will reach the router?

Thanks in advance, Idan

Upvotes: 0

Views: 461

Answers (2)

Mosab Shaheen
Mosab Shaheen

Reputation: 1174

  1. if the packet/message is sent to a host on the same subnet/vlan then it will be sent to to the host directly because it is at one hope distance (in layer3) from the origional host that's why the router is not included (however, behind the scenes it can be at many hopes in layer2 if there are swithes in between. A host has ARP table containing the MAC addresses and a switch has "Mac Address Table" which will forward the packet from a switch port to another till it reaches the second host without passing through the router).

  2. If the NAT table in the router resets, obviously there is no way to track back which received packet belongs to whom and they will be dropped.

Upvotes: 0

Benjamin T
Benjamin T

Reputation: 8311

  1. The separation is made by your network card based on your IP configuration.

Your IP configuration is composed of:

  • An IP address e.g 192.168.1.1
  • A mask e.g 255.255.255.0
  • A gateway e.g 192.168.1.2

From the IP address and the mask the card deduce the range of address of your LAN (e.g 192.168.1.0 to 192.168.1.255), if the destination address is in the range of address, the network card send directly the packet to the destination machine. If the destination address is outside of the range, the packet is sent to the gateway. The gateway (which is basically your router) will forward the packet, eventually using NAT.

  1. If the NAT table has been reset, the router cannot know to which machine the incoming packet is for, it will most probably drop it.

Upvotes: 1

Related Questions