是的,我想知道公共IPv4地址空间中可能的IP总数。
我不确定在哪里可以获得所有IP地址范围的整洁列表,所以有人能指点我一个资源让我自己计算或者为我计算出总的IP数量吗?
此外,我的意思是公共IP,不包括保留或私有IP地址范围。只计算能够通过互联网访问的IP。
是的,我想知道公共IPv4地址空间中可能的IP总数。
我不确定在哪里可以获得所有IP地址范围的整洁列表,所以有人能指点我一个资源让我自己计算或者为我计算出总的IP数量吗?
此外,我的意思是公共IP,不包括保留或私有IP地址范围。只计算能够通过互联网访问的IP。
根据保留IP地址,有588,514,304个保留地址。由于总共有4,294,967,296(2^32)个IPv4地址,因此有3,706,452,992个公共地址。
这篇文章中有太多地址了。
对于IPv4,这个地址池的大小是32位(2³²),包含了4,294,967,296个IPv4地址。
在IPv6的情况下
IPv6地址空间的大小为128位(2¹²⁸),其中包含340,282,366,920,938,463,463,374,607,431,768,211,456个IPv6地址。其中包括保留IP地址。
https://www.ripe.net/internet-coordination/press-centre/understanding-ip-addressing
Reserved address blocks
Range Description Reference
0.0.0.0/8 Current network (only valid as source address) RFC 6890
10.0.0.0/8 Private network RFC 1918
100.64.0.0/10 Shared Address Space RFC 6598
127.0.0.0/8 Loopback RFC 6890
169.254.0.0/16 Link-local RFC 3927
172.16.0.0/12 Private network RFC 1918
192.0.0.0/24 IETF Protocol Assignments RFC 6890
192.0.2.0/24 TEST-NET-1, documentation and examples RFC 5737
192.88.99.0/24 IPv6 to IPv4 relay (includes 2002::/16) RFC 3068
192.168.0.0/16 Private network RFC 1918
198.18.0.0/15 Network benchmark tests RFC 2544
198.51.100.0/24 TEST-NET-2, documentation and examples RFC 5737
203.0.113.0/24 TEST-NET-3, documentation and examples RFC 5737
224.0.0.0/4 IP multicast (former Class D network) RFC 5771
240.0.0.0/4 Reserved (former Class E network) RFC 1700
255.255.255.255 Broadcast RFC 919
对于马尔科回答中的一个小错误进行更正:由于以下事实,某些普通计算方法无法直接生成确切的数字: 有效的IP地址也不应以二进制0或1序列结尾,这些序列与子网掩码中的零序列具有相同的长度。因此最终答案实际取决于子网总数(马尔科的答案- 2 * 子网总数)。
https://github.com/stephenlb/geo-ip将生成一个包括地点在内的有效的公网IP地址列表。
'1.0.0.0/8'
至 '191.0.0.0/8'
是有效的公网IP地址范围,不包括保留的私有IP地址,如下所示:
import iptools
## Private IP Addresses
private_ips = iptools.IpRangeList(
'0.0.0.0/8', '10.0.0.0/8', '100.64.0.0/10', '127.0.0.0/8',
'169.254.0.0/16', '172.16.0.0/12', '192.0.0.0/24', '192.0.2.0/24',
'192.88.99.0/24', '192.168.0.0/16', '198.18.0.0/15', '198.51.100.0/24',
'203.0.113.0/24', '224.0.0.0/4', '240.0.0.0/4', '255.255.255.255/32'
)
生成包含IP地址和关联地理信息的JSON数据。
请注意,可用的公共IP地址范围是从'1.0.0.0/8'
到'191.0.0.0/8'
,排除下文自述中列出的保留私有IP地址范围。
docker build -t geo-ip .
docker run -e IPRANGE='54.0.0.0/30' geo-ip ## a few IPs
docker run -e IPRANGE='54.0.0.0/26' geo-ip ## a few more IPs
docker run -e IPRANGE='54.0.0.0/16' geo-ip ## a lot more IPs
docker run -e IPRANGE='0.0.0.0/0' geo-ip ## ALL IPs ( slooooowwwwww )
docker run -e IPRANGE='0.0.0.0/0' geo-ip > geo-ip.json ## ALL IPs saved to JSON File
docker run geo-ip
扫描所有有效公共地址的稍快选项:
for i in $(seq 1 191); do \
docker run -e IPRANGE="$i.0.0.0/8" geo-ip; \
sleep 1; \
done
{"city": "Palo Alto", "ip": "0.0.0.0", "longitude": -122.1274,
"continent": "North America", "continent_code": "NA",
"state": "California", "country": "United States", "latitude": 37.418,
"iso_code": "US", "state_code": "CA", "aso": "PubNub",
"asn": "11404", "zip_code": "94107"}
该存储库中的Dockerfile将排除不可用的IP地址,遵循维基百科文章的指南:https://en.wikipedia.org/wiki/Reserved_IP_addresses
Dockerfile导入由https://www.maxmind.com/en/home提供的免费公共数据库。
127.0.0.1
、127.0.0.2
、127.0.0.3
,有时也会使用127.0.0.4
,这些都是在监听相同端口的不同 Web 服务器。我认为它还会用127.0.1.1
来做一些事情。 - ctrl-alt-delor