文章内容
2020/9/24 14:53:58,作 者: 黄兵
IP地址的一些总结
最近项目需要了解IP相关知识,经过学习,总结如下:
IP地址分为5类:
下面是维基百科借的一张表:
Class | Leading bits | Size of network number bit field | Size of rest bit field | Number of networks | Addresses per network | Total addresses in class | Start address | End address | Default subnet mask in dot-decimal notation | CIDR notation |
---|---|---|---|---|---|---|---|---|---|---|
Class A | 0 | 8 | 24 | 128 (27) | 16,777,216 (224) | 2,147,483,648 (231) | 0.0.0.0 | 127.255.255.255[a] | 255.0.0.0 | /8 |
Class B | 10 | 16 | 16 | 16,384 (214) | 65,536 (216) | 1,073,741,824 (230) | 128.0.0.0 | 191.255.255.255 | 255.255.0.0 | /16 |
Class C | 110 | 24 | 8 | 2,097,152 (221) | 256 (28) | 536,870,912 (229) | 192.0.0.0 | 223.255.255.255 | 255.255.255.0 | /24 |
Class D (multicast) | 1110 | not defined | not defined | not defined | not defined | 268,435,456 (228) | 224.0.0.0 | 239.255.255.255 | not defined | not defined |
Class E (reserved) | 1111 | not defined | not defined | not defined | not defined | 268,435,456 (228) | 240.0.0.0 | 255.255.255.255[b] | not defined | not defined |
可以看到这5类的地址总数,以及一些表示方法。
同时这些地址里面有一些并不是公共可用的,一些私有地址:169.254/16,还有一些环回地址:127.0/8,还有一些多播地址,一些保留地址等。
具体私有地址可以参考这篇文章:Private network
保留IP地址可以看这里:保留IP地址
下面是表示所有ABC类地址的写法:
self._class_a = '0.0.0.0/1' self._class_b = '128.0.0.0/2' self._class_c = '192.0.0.0/3'
这里使用的CIDR表示方法,具体可以参考这里:Classless Inter-Domain Routing
经过统计IP数量,与上面ABC类地址相同。
参考资料:
评论列表