【问题标题】:How to know which IP is after a certain number of IPs一定数量的IP后如何知道哪个IP
【发布时间】:2020-06-07 03:00:06
【问题描述】:

我正在研究 RIPE 委派统计数据

文件中每一行的格式如下:

registry|cc|type|start|value|date|status[|extensions...]

start 和 value 的含义如下:

start: This is the IPv4 'first address' of the range.

value: In the case of IPv4 address the count of hosts for this range. This count does not have to represent a CIDR range.

开始和值的例子:

196.4.163.0|768

41.74.0.0|4096

195.35.104.64|192 

198.54.38.0|1536

216.252.155.0|256

141.226.144.0|10240 

93.242.1.0|20224 

193.53.200.0|11520

我如何知道最终使用哪个 IP?

非常感谢!

--- 更新----

我想出了如何解决这个问题。

将第一个 IP 转换为十进制数,然后将值添加到它,然后转换回 ip

【问题讨论】:

  • 许多地址范围无法转换为 CIDR 表示法。只有网络大小为 2^n 并且从它的倍数开始。

标签: python ipv4 delegation


【解决方案1】:

ipcalcsipcalcpure Bash 都可以解决问题。

如需更多答案,包括示例,请参阅:https://serverfault.com/q/54981

对于 Python,你可以只使用内置的 https://docs.python.org/3/library/ipaddress.html 或只使用 structsocket 内置的 https://stackoverflow.com/a/44043448

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 2012-05-27
    • 2014-07-07
    • 2014-07-15
    • 2012-10-12
    • 2016-12-20
    • 2012-01-30
    相关资源
    最近更新 更多