The easy way to record:
Example: 100.102.10.20/27
Step 1: Convert the subnet mask
27 ==》 255.255.255.224
Step 2: What we need to deal with is where the subnet mask is not 255, so calculate the 224 part
因为0-255有256个,所以用256-224=32 ==>2^5从最后一段借了3位
Step 3: You can see the network bit:
从0开始划分: 0,32,64,96,128,160,192,224,256
Step 4: Compare which part of the last digit of the IP address is divided in the third step:
20 ==》 0 - 32 之间
Step 5: It can be deduced that:
网络地址为: 100.102.10.0
广播地址为:100.102.10.31(32是下一个网段的网络地址,所以需要减1)
Other examples:
10.145.129.20/21
Network address: 10.145.128.0
Broadcast address: 10.145.135.255