IPv6的IPv4的净功能略有不同。为什么?

发布于 2025-01-30 19:37:24 字数 978 浏览 2 评论 0原文

我正在使用BigQuery截断IPv4& IP46 IP地址。我的意思是我想放下可能用于识别真实人的部分。

以下是一些演示代码:

select *,
        NET.IP_TO_STRING(NET.IP_TRUNC(NET.IP_FROM_STRING(v.IPv4Address), 24)),
        NET.IP_TO_STRING(NET.IP_TRUNC(NET.IP_FROM_STRING(v.IPv6Address), 64))
from (
  select struct(
     "254.34.78.20" as `IPV4Address`,
     "2a02:c7e:3f0d:e00:48e:abff:d697:9cc2" as `IPv6Address`
  ) as v
)

返回:

vf0_f1_
{“ ipv4Address”:“ 254.34.78.20”,“ ipv6address”:“ 2A02:C7E:3F0D:3F0D:E00:E00:48E:ABFF:ABFF:ABFF:ABFF:D697:D697:9CC2“}254.34.78.78.78.08.02a: C7E02A:C7E02A:C7E02A:C7E02A:C7E 。 :3f0d:e00 ::

我只是想知道为什么这些功能为IPv4地址的截断部分返回0,而对于IPv6地址的截断部分,没有任何功能。

我知道这并不是一个真正的问题本身,因为它更多地是关于网络的,我怀疑Bigquery只是在做其他任何此类图书馆会做的事情……但有兴趣知道为什么这是如此。也许我也会用ipv6标记它

I'm using BigQuery to truncate IPv4 & IP46 IP addresses. By that I mean I want to drop the part that might be used to identify a real person.

Here's some demo code:

select *,
        NET.IP_TO_STRING(NET.IP_TRUNC(NET.IP_FROM_STRING(v.IPv4Address), 24)),
        NET.IP_TO_STRING(NET.IP_TRUNC(NET.IP_FROM_STRING(v.IPv6Address), 64))
from (
  select struct(
     "254.34.78.20" as `IPV4Address`,
     "2a02:c7e:3f0d:e00:48e:abff:d697:9cc2" as `IPv6Address`
  ) as v
)

It returns:

vf0_f1_
{ "IPV4Address": "254.34.78.20", "IPv6Address": "2a02:c7e:3f0d:e00:48e:abff:d697:9cc2" }254.34.78.02a02:c7e:3f0d:e00::

I'd simply like to know why these functions return a 0 for the truncated portion of the IPv4 address but nothing for the truncated portion of the IPv6 address.

I know this isn't really a BigQuery question per se as its more about networks and I suspect BigQuery is just doing what any other such library would do... but interested to know why this is nonetheless. Maybe I'll tag it with IPv6 too

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待"谢繁草 2025-02-06 19:37:24

我只是想知道为什么这些功能返回0
IPv4地址的截断部分,但没有任何截断的
IPv6地址的部分。

IT IS 返回0 IPv6地址的截断部分。

IPv6地址可以具有多种形式,但是规范表单要求您缩短具有双重船体的0字段的最长运行(::)。那是在您的地址的末尾2A02:C7E:3F0D:E00 ::,这意味着它是2A02:C7E:3F0D:E00:e00:0:0:0:0:0:0:0 正确缩短。

I'd simply like to know why these functions return a 0 for the
truncated portion of the IPv4 address but nothing for the truncated
portion of the IPv6 address.

It is returning 0 for the truncated part of the IPv6 address.

IPv6 addresses can have several forms, but the canonical form requires you to shorten the longest run of 0 fields with a double colon (::). That is at the end of your address 2a02:c7e:3f0d:e00::, and that means it is 2a02:c7e:3f0d:e00:0:0:0:0 properly shortened.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文