3

Case 1: PC A: 192.168.1.2 / 24, and it connects to LAN port1 of router A PC B: 192.168.2.3 / 24, and it connects to LAN port2 of router A Given above we know A and B can't talk to each other due to different subnets

Case 2: PC A: 192.168.1.2 / 24, and it connects to LAN port1 of router A PC B: 192.168.2.3 / 24, and it connects to LAN port1 of router B router A: its WAN port connects to router B's LAN port 2, router B has been configured to route packets for PC A to router A

My question: in case 2, the packet will move in the path PC B -> router B -> router A -> PC A successfully, however I wonder since the packet still has its source IP as 192.168.2.3 and target IP as 192.168.1.2 which are of different subnet, when PC A receives the packet, it will still check the packet's source IP with 255.255.255.0 to get PC B's subnet which will be different from PC A's like how it will in Case 1, which should again prevent the packet from reaching PC A. What has the router done to make the packet successfully reach?

Many thanks!

1
  • Routers route between subnets (=forward by destination IP address). That is their purpose. PC A: 192.168.1.2 / 24, and it connects to LAN port1 of router A PC B: 192.168.2.3 / 24 That isn't even possible. The gateway needs to share a subnet with the host. 192.168.1.0/24 and 192.168.2.0/24 are different subnets.
    – Zac67
    Sep 6, 2021 at 18:50

1 Answer 1

3

I wonder since the packet still has its source IP as 192.168.2.3 and target IP as 192.168.1.2 which are of different subnet, when PC A receives the packet, it will still check the packet's source IP with 255.255.255.0 to get PC B's subnet which will be different from PC A's like how it will in Case 1, which should again prevent the packet from reaching PC A.

No. A host receiving an IP packet only cares that the destination IP address is its IP address. It does not care what the source address is for the purpose of accepting the packet.

As explained in this answer, the problem of two different network-layer networks on the same data-link network is that the source host will not send a frame to the destination host if the network-layer destination address is for a different network-layer network.

The source sends a datalink frame for a packet destined to a different network-layer network to its configured gateway (router), not the destination host data-link address, so the destination host on the same data-link network but a different network-layer network will never get the frame with the IP address.


Bridges (including switches) deliver data-link frames on the same data-link network, but the source host will not use the data-link address for a host on a different network-layer network. Routers route network-layer packets between different network-layer networks, so each router interface has an address in a different network-layer network.

3
  • Very well explained! thanks a lot! So actually the subnet mask operation to figure out the subnet address is done on the sender's end before sending rather than the receiver's end before receiving? Sep 6, 2021 at 19:36
  • Yes, the sender determines where it sends the frame that encapsulates the packet.
    – Ron Maupin
    Sep 6, 2021 at 19:38
  • Correct. The subnet mask is used by the sender to determine if the destination host is on the same network as itself or not.
    – JFL
    Sep 6, 2021 at 19:39

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.