从这五个问题,来彻底了解ip地址的计算
portant; overflow-wrap: break-word !important; background-color: rgb(255, 251, 0);">portant; overflow-wrap: break-word !important; color: rgb(62, 62, 62); font-family: Optima-Regular, PingFangTC-light; font-size: 15px; letter-spacing: 0.544px; text-align: left; text-indent: 34px;">已知一个ip地址是192.168.1.1,子网掩码是255.255.255.0,那么它的网络地址是多少?
portant; overflow-wrap: break-word !important;">在了解这个问题之前,我们先需要了解下,什么是网络地址?
portant; overflow-wrap: break-word !important;">ipP地址是由两部分组成:网络地址+主机地址。
portant; overflow-wrap: break-word !important;">网络地址可以确定ip地址的范围,ip地址其实跟身份证号比较像。
portant; overflow-wrap: break-word !important; color: rgb(217, 33, 66);">portant; overflow-wrap: break-word !important;">一个人身份证:portant; overflow-wrap: break-word !important;">共18位:
portant; overflow-wrap: break-word !important;">前6位表示的是省、市、县区;
portant; overflow-wrap: break-word !important;">7到14位表示是出生年月,
portant; overflow-wrap: break-word !important;">15、16位表示是派出所。
portant; overflow-wrap: break-word !important;">第17位是性别。
portant; overflow-wrap: break-word !important;">而网络号就是相当于身份证的省、市、县区。
portant; overflow-wrap: break-word !important;">那么如何来算出网络地址呢?
portant; overflow-wrap: break-word !important; font-size: 15px;">详细计算
portant; overflow-wrap: break-word !important; font-size: 15px;">将ip地址192.168.1.1转换为二进制
portant; overflow-wrap: break-word !important; font-size: 15px;">11000000.10101000.00000001.00000001portant; overflow-wrap: break-word !important; font-size: 15px;">
portant; overflow-wrap: break-word !important; font-size: 15px;">将子网掩码255.255.255.0转换成二进制
portant; overflow-wrap: break-word !important; font-size: 15px;">11111111.11111111.11111111.00000000
portant; overflow-wrap: break-word !important; font-size: 15px;">然后将两者相“与(and)"运算:
portant; overflow-wrap: break-word !important; font-size: 15px;">inkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.544px; box-sizing: border-box !important; overflow-wrap: break-word !important;">11000000.inkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.544px; box-sizing: border-box !important; overflow-wrap: break-word !important;">10101000.inkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.544px; box-sizing: border-box !important; overflow-wrap: break-word !important;">00000001.inkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.544px; box-sizing: border-box !important; overflow-wrap: break-word !important;">00000001portant; overflow-wrap: break-word !important; font-size: 15px;">
portant; overflow-wrap: break-word !important; font-size: 15px;">11111111.11111111.11111111.00000000
portant; overflow-wrap: break-word !important; font-size: 15px;">然后得到:
portant; overflow-wrap: break-word !important; font-size: 15px;">inkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.544px; box-sizing: border-box !important; overflow-wrap: break-word !important;">11000000.10101000.00000001.00000000
portant; overflow-wrap: break-word !important; font-size: 15px;">转换成网络地址就是:192.168.1.0
portant; overflow-wrap: break-word !important; color: rgb(62, 62, 62); font-family: Optima-Regular, PingFangTC-light; font-size: 15px; letter-spacing: 0.544px; text-align: left; text-indent: 34px; background-color: rgb(255, 251, 0);">已知某主机的ip地址是192.168.100.200,子网掩码为255.255.255.192,其网络内可用的ip地址个数为多少?
portant; overflow-wrap: break-word !important; font-size: 15px;">详细计算
portant; overflow-wrap: break-word !important; font-size: 15px;">将子网掩码255.255.255.192转换为二进制
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">11111111.11111111.11111111.11000000
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">子网掩码共有26位,还有6位可用。
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">即2的6次方减去2,等于62,即有62个ip地址可用。
portant; overflow-wrap: break-word !important; background-color: rgb(255, 251, 0);">portant; overflow-wrap: break-word !important; color: rgb(62, 62, 62); font-family: Optima-Regular, PingFangTC-light; font-size: 15px; letter-spacing: 0.544px; text-align: left; text-indent: 34px;">某公司申请到一个C 类IP 地址,只连接6 个子公司,最大的一个子公司有26 台计算机,每个子公司都分配在同一个网段,则子网掩码应设为多少合适?
portant; overflow-wrap: break-word !important;">首先一个C类的子网掩码为255.255.255.0,这个是最原始。portant; overflow-wrap: break-word !important;">但现在我们是有要求:
portant; overflow-wrap: break-word !important;">1、连接6个子网
portant; overflow-wrap: break-word !important;">2、且最大一个子网的ip地址为26个。
portant; overflow-wrap: break-word !important;">
portant; overflow-wrap: break-word !important;">如何来设置这个子网掩码呢?portant; overflow-wrap: break-word !important; font-size: 15px;">
portant; overflow-wrap: break-word !important; font-size: 15px;">详细计算
portant; overflow-wrap: break-word !important; font-size: 15px;">网络中的原则是ip地址与子网掩码越越精准,portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">网portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">络越易管理,故障越低。portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">首先来portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">分portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">析2的2次方portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">等于4,2的3portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">次方等portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">于portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">8,
portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">所以最准确portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">网portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">络中是portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">容portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">纳8个子网,最接近6个子网的划分portant; overflow-wrap: break-word !important; letter-spacing: 0.544px; font-size: 15px;">即为255.255.255.224。portant; overflow-wrap: break-word !important; font-size: 15px;">我们再来验证下,每个子网的主机数量。portant; overflow-wrap: break-word !important; font-size: 15px;">portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">子网掩码255.portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">255.255.portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">224转化为二进制为:
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px; color: rgb(217, 33, 66);">11111111.11111111.11111111.111portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">00000
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">子网掩码为27位,那么主机位数为5位。
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">即可容纳的主机数为2的5次方减2,等于30。
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">完全符合一个子网内容纳26个ip地址。
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">所以最终的子网掩码为255.255.255.224portant; overflow-wrap: break-word !important; background-color: rgb(255, 251, 0);">portant; overflow-wrap: break-word !important; font-size: 15px;">一个A类ip地址的子网掩码是255.255.240.0,共有几位被用来划分子网?portant; overflow-wrap: break-word !important; font-size: 15px;">且可以划分多少个子网?每个子网ip地址数量是多少?
portant; overflow-wrap: break-word !important; font-size: 15px;">详细计算
portant; overflow-wrap: break-word !important; font-size: 15px;">将子网掩码255.255.240.0转换为二进制
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">11111111.11111111.11110000.00000000
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">子网掩码共有20位,而一个A类的ip地址的子网掩码是8位,即有12位被用来划分子网。
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">所以子网数为:2的12次方=4096个子网。
portant; overflow-wrap: break-word !important; color: rgb(217, 33, 66);">portant; overflow-wrap: break-word !important; font-size: 15px;">那么每个子网的主机数是多少呢?
portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">因为ip地址为32位,网络号已为20位,则主机数12位。portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">每个子网中的ip数量为portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">2^12=4096,但是能够分配给计算机使用的只有4096-2=4094个,(减去一个网络地址与一个广播地址)。portant; overflow-wrap: break-word !important; background-color: rgb(255, 251, 0);">portant; overflow-wrap: break-word !important; color: rgb(0, 0, 0); font-size: 15px;">10.135.255.19/255.255.255.248的广播地址是什么?
portant; overflow-wrap: break-word !important; font-size: 15px;">计算思路,要得到广播,先得出网络地址,然后把网络地址的主机位全换成1,便就是广播地址。
portant; overflow-wrap: break-word !important; font-size: 15px;">详细计算
portant; overflow-wrap: break-word !important; font-size: 15px;">将ip地址10.135.255.19转换为二进制
portant; overflow-wrap: break-word !important; font-size: 15px;">00001010.10001001.11111111.00010011
portant; overflow-wrap: break-word !important; font-size: 15px;">将子网掩码255.255.255.248转换成二进制
portant; overflow-wrap: break-word !important; font-size: 15px;">11111111.11111111.11111111.11111000
portant; overflow-wrap: break-word !important; font-size: 15px;">然后将两者相“与(and)"运算:
portant; overflow-wrap: break-word !important; font-size: 15px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">00001010.10001001.11111111.portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">00010011
portant; overflow-wrap: break-word !important; font-size: 15px;">11111111.11111111.11111111.11111000
portant; overflow-wrap: break-word !important; font-size: 15px;">然后得到:
portant; overflow-wrap: break-word !important; font-size: 15px;">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">00001010.10001001.11111111.portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">00010000
portant; overflow-wrap: break-word !important; font-size: 15px;">转换成网络地址就是:10.135.255.16
portant; overflow-wrap: break-word !important; font-size: 15px;">那么广播地址是多少呢?portant; overflow-wrap: break-word !important; font-size: 15px;">
portant; overflow-wrap: break-word !important; font-size: 15px;">从子网掩码可以看出,这个子网掩码是29位。
portant; overflow-wrap: break-word !important; font-size: 15px; color: rgb(217, 33, 66);">11111111.11111111.11111111.11111portant; overflow-wrap: break-word !important; font-size: 15px;">000
portant; overflow-wrap: break-word !important; font-size: 15px;">也就是主机数还有3位可用。portant; overflow-wrap: break-word !important; font-size: 15px; color: rgb(217, 33, 66);">portant; overflow-wrap: break-word !important; letter-spacing: 0.544px;">00001010.10001001.11111111.00010portant; overflow-wrap: break-word !important; font-size: 15px;">000
portant; overflow-wrap: break-word !important; font-size: 15px;">把网络地址的后面三个零全换成1。
portant; overflow-wrap: break-word !important; font-size: 15px;">即可得出广播地址为:portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">10.135.255.2portant; overflow-wrap: break-word !important; font-size: 15px; letter-spacing: 0.544px;">3