首页 > IT基础架构 > 网络安全 > 如何快速的计算subnet和broadcast
根据IP地址和掩码如何快速计算出子网和广播地址?
IP地址:201.222.10.60,掩码:255.255.255.248
计算过程:
256 -248=8 60/8 =7 SUBNET= 7*8 BROADCAST =8*8-1
result: SUBNET=201.222.10.56 BROADCAST =201.222.10.63
再计算一个:address:15.16.193.6,subnetMask:255.255.248.0
计算过程:
256-248=8 193/8=24 SUBNET=24*8=192 BROADCAST =25*8-1
result: SUBNET=15.16.192.0 BROADCAST =15.16.199.255
Just calculate:
broadcast = ip | ( ~ subnet )
(Broadcast = ip-addr or the inverted subnet-mask)
The broadcast address has a 1 bit where the subnet mask has a 0 bit.
255.255.255.128 --> IP前3位固定(因为ip和subnet做AND运算)
前三位IP码由分配下来的数字就只能固定为192.168.0 所以就只剩下了最后的一位了,那么显而易见了,ip地址只能有(2的8次方-2),即256-2=254,一般主机地址全为0或者1(二进制)有其特殊的作用。
Refer to: http://wjhu.iteye.com/blog/1403019
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26477398/viewspace-2122436/ ,如需转载,请注明出处,否则将追究法律责任。