LAN Packet Routing – Sending Packet to Another PC on Different Network

arplanmacNetwork

What happens if, say PC A(192.168.2.2) tries to send a packet to PC B(10.0.2.3) connected through LAN(only 2 computers are connected in this case PC A and PC B) as there is no router or a switch involved to forward the packet.
Let me make my question more understandable.

1)Ive used static IP so that its possible for me to use IP adress of my choice.

2)Now if PC A is trying to send a packet to PC B, it first looks at the IP address. In this case, IP of PC B is 10.0.2.3 and judging from the IP it looks like its intended for another network.

3)The next step would be to send it to the default gateway, but in this case we only have used 2 PCs and are only connected through a LAN cable and there is neither a router nor a switch.

It can send an ARP request only if its sure that they are in the same network, right?
So how does PC A send a packet to PC B without knowing its MAC address?

Best Answer

Packet forwarding decisions will always depend on the defined routes. There's only 3 outcome:

  1. Route defined, network reached: Forward (ARP request sent to find destination MAC address).
  2. Route not defined, default gateway: Forward (ARP request sent to find default gateway MAC address).
  3. Route not defined, no default gateway: Drop.

Without a router (gateway), you'll need to route the traffic yourself. Here's 2 solutions:

  • Add a route on each device that points to the other

  • (or) Add a default gateway on each device that points to the other

Related Topic