码迷,mamicode.com
首页 > 其他好文 > 详细

IP地址的基本换算实例

时间:2015-04-21 01:59:22      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:ip地址   主机   

IP地址:

00000000. 00000000. 00000000. 00000000

11111111. 11111111. 11111111. 11111111

0.0.0.0               -                 255.255.255.255

 

A类:      前八位第一位为0IP地址,为A类:

00000001.0.0.0

01111111.255.255.255

 

         子网掩码:     255.0.0.0

                                     11111111.00000000.00000000.00000000

 

                   10.0.0.1

                   255.255.255.0

 

         1.0.0.0              

         126.255.255.255

         A类:      网段数:         27  只有126个网段

                            主机数:         224 – 2      =       16777216– 2   = 166777214

 

                   127.0.0.1         

B类:      前八位用10开头的,为B类:

10000000.0.0.0

10111111.255.25.255

 

         128.0.0.0

         191.255.255.255

 

         子网掩码:255.255.0.0

 

         B类:      网段数:         214  16384个网段

                            主机数:         216 – 2 =65536 -2 = 65534

 

C类:      前八位用110开头,为C

11000000.0.0.0

11011111.255.255.255

 

         192.0.0.0

         223.255.255.255

 

         192.168.216.250

         255.0.0.0

 

         子网掩码:255.255.255.0

 

         C类:      网段数:         221

                            主机数:         28 -2 = 256-2 =254

 

D类:     前八位用1110开头,为D

11100000.0.0.0

11101111.255.255.255

 

         224.0.0.0

         239.255.255.255

 

E类:      前八位用1111开头,为E

11110000.0.0.0

11111111.255.255.255

 

         240.0.0.0

         255.255.255.255

 

 

私有IP地址:

         A           10.0.0.0  -   10.255.255.255

                            255.0.0.0

         B           172.16.0.0        -        172.31.255.255

                            255.255.0.0

         C           192.168.0.0     -        192.168.255.255

                            255.255.255.0

 

总结:

         1、可用IP地址分为ABC三类

         2、每个类别的IP地址中,都有一部分私有IP地址

         3、子网掩码必须和IP地址成对出现

         4、每个网段都有默认子网掩码,用来区分网络位和主机位

 

子网掩码划分:

         如果子网掩码是1,那么和他对应的IP地址代表网络位

         如果子网掩码是0,那么和他对应的IP地址代表主机位

         子网掩码只要是连续的1,就可用

 

192.168.1.100                   11000000.10101000.00000001.01100100     /26

255.255.255.128               11111111.11111111.11111111.10000000

         子网划分:

                   21网段数                          2

                   主机数:                            27  =128

                   IP的网络地址:        192.168.1.0

                   IP的广播地址:        192.168.1.127

 

192.168.1.100                   11000000.10101000.00000001.01100100

255.255.255.192               11111111.11111111.11111111.11000000

                                               11000000.10101000.00000001.01000000               192.168.1.64

                                               11000000.10101000.00000001.01111111               192.168.1.127

 

 

                   网段数:         22     =  4

                   主机数:         26 – 2 = 64 - 2  =  62

                   网络地址:     192.168.1.64

                   广播地址:     192.168.1.127

 

1       1                1

1       0                0

0       1                0

0       0                0

 

子网掩码计算公式:

         网络地址:     IP地址和子网掩码的二进制相与,得到的就是网络地址

         广播地址:     子网掩码中有几个0,就把IP地址的对应位数换成1,得到的就是广播地址

         网段数:         在有效子网中,有n1,网段数是2n次方

         主机数:         在有效子网中,有m0,主机数就是2m次方减2

 

192.168.1.213                   11000000.10101000.00000001.11010101

255.255.255.240               11111111.11111111.11111111.11110000

网络地址:                       11000000.10101000.00000001.11010000               192.168.1.208

广播地址:                       11000000.10101000.00000001.11011111               192.168.1.223

网段数:                   2*4   =  16

主机数:                   2*4 -2  =  14

 

192.168.1.139                   11000000.10101000.00000001.10001011

255.255.255.248               11111111.11111111.11111111.11111000

网络地址:                       11000000.10101000.00000001.10001000               192.168.1.136

广播地址:                       11000000.10101000.00000001.10001111               192.168.1.143

网段数:                            2*5  =     32

主机数:                            2*3-2=6

 

192.168.1.179                  

255.255.255.252               11111111.11111111.11111111.11111100

         网络地址:     192.168.1.176

         广播地址:     192.168.1.179

         网段数:         2*6 = 64

         主机数:         2*2 - 2 = 2

 

192.168.1.97            11000000.10101000.00000001.01100001

255.255.254.0          11111111.11111111.11111110.00000000

.网络地址:             11000000.10101000.00000000.00000000               192.168.0.0

广播地址:              11000000.10101000.00000001.11111111               192.168.1.255

网段数:         2*7

主机数:         2*9-2

 

         172.16.0.0        11111110.00010000.00000000.00000000

         255.255.254.0  11111111.11111111.11111110.00000000

         网络地址位:11111110.00010000.00000000.00000000  172.16.0.0

         广播位:         11111110.00010000.00000001.11111111  127.16.1.255

         网络位:         215

         主机位:         29-2

 

61.1.1.1

255.255.255.240

 

子网掩码表格:

11111111.11111111.11111111.00000000

 

二进制              十进制                       网段数              主机数

00000000         255.255.255.0          1                          254

10000000         255.255.255.128     2                          126

11000000         255.255.255.192     4                          62

11100000         255.255.255.224     8                          30

11110000         255.255.255.240     16                       14

11111000         255.255.255.248     32                       6

11111100         255.255.255.252     64                       2

 

10.168.211.49          00001010.10101000.11010011.00110001

255.240.0.0               11111111.11110000.00000000.00000000

         网络地址位:00001010.10100000.00000000.00000000  10.160.0.0

         广播位:         00001010.10101111.11111111.11111111     10.175.255.255

         网络位:212

              主机位:220-2

 

172.16.199.217        10100010.00010000.11000111.11011001

255.255.224.0          11111111.11111111.11100000.00000000

         网络地址位:10100010.00010000.11000000.00000000  172.16.192.0

         广播地址位:10100010.00010000.11011111.11111111  172.16.223.255

         网络位:23

              主机位:213-2

172.16.205.168        10100010.00010000.11001101.10101000.

255.255.255.240     11111111.11111111.11111111.11110000

         网络地址位:10100010.00010000.11001101.10100000127.16.205.160

         广播地址位:10100010.00010000.11001101.10101111127.16.205.175

         网络位:    24

         主机位:        24-2

192.168.1.167          11000000.10101000.00000001.10100111

255.255.248.0          11111111.11111111.11111000.00000000

         网络位地址:11000000.10101000.00000000.00000000               192.168.0.0

         广播位:         11000000.10101000.00000111.11111111               192.168.7.255

         网络位:         25

         主机位:         211-2



本文出自 “吴老二” 博客,请务必保留此出处http://9827789.blog.51cto.com/9817789/1636268

IP地址的基本换算实例

标签:ip地址   主机   

原文地址:http://9827789.blog.51cto.com/9817789/1636268

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!