A little confused about subnet masks

ipnetworkingrouting

I still don't have a really clear understanding of subnet masks, and I want to understand it better, but right now I urgently need an answer to just one question:

If my computer's subnet mask is 255.255.0.0, can I connect directly to a device with a subnet mask of 255.255.255.0?

For instance, if I had my PC set up with an IP address of 192.168.1.100, with a subnet mask of 255.255.0.0, and a gateway of 192.168.1.1, would I be able to directly connect to a device (e.g. Raspberry Pi) with an IP address of 192.168.1.150, with a subnet mask of 255.255.255.0, and a gateway of 192.168.1.1?

Please let me know.

Thanks!

Best Answer

  • This setup is incorrect, but it will work in the case where both IPs are legal in both networks.

    The reason is that nodes find one another through ARP requests where a request is broadcast, for example, asking "Who has 192.168.1.150, tell 192.168.1.100".

    The request will pass through all connected routers/switches, since the ARP request does not include any data about subnet masks, only about IP and MAC address.

    Once 192.168.1.150 (or its router) received the request, it will answer with the MAC address of 192.168.1.150. From now on communication will pass to Layer 2, also known as the Data link layer.

    The Layer 2 frames will use MAC address as source and destination, which the router/switch will happily pass along.

  • Related Question