捕获用户IP地址信息进行审计

发布于 2024-08-27 11:08:14 字数 205 浏览 4 评论 0原文

我们需要记录使用基于 Java EE 5 的某个 Web 应用程序的所有用户的 IP 地址信息。

在以下支持的数据库(h2、mysql、oracle)中存储 IPv4 或 IPv6 地址的合适 sql 数据类型是什么? ?

还需要过滤来自某些 IP 地址的活动。我是否应该将表示形式视为字符串字段(例如 varchar(32) 来保存 ipv4、ipv6 地址)?

We have a requirement to log IP address information of all users who use a certain web application based on Java EE 5.

What would be an appropriate sql data type for storing IPv4 or IPv6 addresses in the following supported databases (h2, mysql, oracle)?

There is also a need to filter activity from certain IP addresses. Should I just treat the representation as a string field (say varchar(32) to hold ipv4, ipv6 addresses)?

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

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

发布评论

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

评论(3

妖妓 2024-09-03 11:08:14

我将 IP 地址存储在 varchar(15) 中。这很容易阅读,您可以过滤特定的 IP,例如 where ip = '1.2.3.4'

如果您必须对网络进行过滤,例如 1.2.3.4/24,那就另当别论了。在这种情况下,您最好将 IP 地址存储为 4 字节二进制文件。

I'd store the IP addresses in a varchar(15). This is easily readable, and you can filter for specific IP's like where ip = '1.2.3.4'.

If you have to filter on networks, like 1.2.3.4/24, it becomes a different story. In that case your better off storing the IP address as a 4 byte binary.

兔姬 2024-09-03 11:08:14

如果您有大量数据并且必须进行搜索,为了提高性能,最好将 IP 的字符串(点)表示形式转换为其正确的整数值。

If you have huge amounts of data and have to search through, for performance it would be better to convert string (dotted) representation of IPs to their proper integer values.

南渊 2024-09-03 11:08:14

其中任何一个都是有效的

  • 4 个字节,也许是 CIDR varchar(15) 或 (18) 的第 5 个字节,
  • 用于一次性存储完整表示

也就是说,varchar(48) 用于 SQL Server 的 sys.dm_exec_connections...

Either of these is valid

  • 4 bytes, perhaps a 5th byte for CIDR
  • varchar(15) or (18) to store full representation in one go

Saying that, varchar(48) for SQL Server's sys.dm_exec_connections...

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