I am studying to receive my ccna and have come across a question that, for some reason, is difficult to conceptualize (at least for me). This is a theoretical question and not what's best practice, as I am sure what I am going to present does not exist intentionally out in the real world.
My Question is: How does a sending host know it's communicating with the right host on the right SUBNET? And if it can't, what are the security-related implications of this?
Consider this setup:
PCA 192.168.1.1 Subnet 255.255.255.0 PCB 192.168.1.2 Subnet 255.255.255.128
Connected via a layer 2 switch on the same vlan\segment.
These machines are technical on different "subnets", one with a range of 0-255, and the other 0-127.
PCA (192.168.1.1) sends traffic to PCB (192.168.1.2) and communication is successful, when technically it shouldn't be. These machines are on the same network address 192.168.1.0. And this test was performed in packet tracer.
Choose an ip for PCB from the next subnet in the /25 network (192.168.1.128); (I have not done packet capturing on this) my assumption is that communication would be allowed 1 way, from PCA -> PCB, but PCB would be aware of it's own subnet and not reply without a route configured.
Are my assumptions\findings true?
*All tests were performed in packet tracer.
EDIT:
I understand how to determine network addresses via subnet masks and the ANDing method. But in the books, they just ask that, by convention, you should avoid overlapping subnets. In VLSM, they say provision the largest network first, then the next largest and so on, without overlapping. But there is nothing technological preventing you from having overlapping ranges and even duplicate ips (at least on a lan). I guess in my example the machines ARE on the same network 192.168.1.0, regardless of how the subnet is sliced. But what are the security implications of this? locally vs internet?