- ip1: 192.168.10.10/23
- ip2: 192.168.11.10/23
- Find the
subnet_ip, then find thenum_hostsin that sub network - using
num_hostsin that subnet find out thestart_address,last_address - if the second ip is in that range then they are of same subnet otherwise not
first 23 bits set to 1
- subnet_mask_in_bin:
11111111.11111111.11111110.00000000 - subnet_mask_in_dec:
255.255.254.0 - num_bits_in_host:
9(num of 0s in the last part of the mask after 1) - num_bits_in_network:
7(num of 1s in the octet that is not all 0s, in this case 3rd octet)
- ip1_in_dec:
192.168.10.10 - ip1_in_bin:
11000000.10101000.00001010.00001010
if there's a 1 in subnet mask move the bit in ip1 down
octets: -- 1 --.-- 2 --.-- 3 --.-- 4 --
ip1_in_bin: 11000000.10101000.00001010.00001010
subnet_mask_in_bin: 11111111.11111111.11111110.00000000
------------------------------------
subnet_in_bin: 11000000.10101000.00001010.00000000
subnet_in_dec: 192.168.10.0- basically choose an octet of the subnet mask that is all 0s
- consider only the 3rd octet of the subnet mask as it is the one determining the subnet
- find number of 1's in that octet (
num_bits_in_network) num_subnets = 2^num_bits_in_networknum_hosts_per_subnet = 2^num_bits_in_host - 2
- from
subnet_mask_in_bin3rd octet is11111110 num_ones = 7num_subnets = 2^7 = 128num_hosts_per_subnet = 2^9 - 2 = 510- so there are 128 subnets with each subnet having 510 hosts
- starting address for subnet (
network_in_binonly consider the network portion)
subnet_in_bin: 11000000.10101000.00001010.00000000
subnet_in_dec: 192.168.10.0
last_address: network_in_dec + 510 (`num_hosts_per_subnet`)
192.168.10.0 + 510 => 192.168.11.254
first_address: 192.168.10.1- Note:
- 192.168.10.0 is not a usable ip address as its reserved for subnet address
- 192.168.11.255 is not a usable ip address as its reserved for subnet address
- basically if the last portion of ip is 0 or 255 then it can't be used by the host, which is why we subtract 2 in
num_hosts_per_subnetcalculation
- We found out that from
ip1: 192.168.10.10/23- the subnet ip
192.168.10.0has 510 hosts- start_address:
192.168.10.1 - last_address:
192.168.11.254
- start_address:
- the subnet ip
- as
ip2: 192.168.11.10/23is inside the range of start_address and last_address we can say that it belongs to the same network
- https://www.youtube.com/watch?v=s_Ntt6eTn94
- https://www.calculator.net/ip-subnet-calculator.html
- more detailed + shortcut method
- https://www.youtube.com/watch?v=qQEaAb_p8_E (understand basics)
- https://www.youtube.com/watch?v=ZxAwQB8TZsM (shortcut to do it in 7 seconds)