IPv4 subnet
How to check if an address belongs to subnet?
You can check your subnet mask.
For example if your subnet mask is 255.255.255.0
, the first 24bits / 3bytes will be the same if you are in same subnet.
e.g. if your ip is 192.0.2.1
, you any other ip in the same subnet should be 192.0.2.X
.
You could also denote this as 192.0.2.1/24, to indicate the first 24bits are reserved.
How to know if device is in same subnet?
Common blocks
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16