IP address field type

The IP Address (Validated IPV4, IPV6) [ip_addr] field type stores valid IPv4 and IPv6 addresses.

Support for IPv4 and IPv6

Both dot-decimal and hex notation are supported for IPv4 and IPv6. For IPv6, you can use the double-colon notation to compress zeros. Familiarize yourself with IETF RFC5952 for examples and guidelines on text representation for IPv6 addresses.

The following are examples of valid IP addresses:
  • A standard IPv4 address in dot-decimal notation:

    10.34.51.20

  • A same IPv4 address in hex notation:

    0x0A223314 or 0A223314

    Note: The optional prefix 0x is supported.
  • A standard IPv6 address in dot-decimal notation:

    1507:f0d0:1002:0051:0000:0000:0000:0004

  • The same IPv6 address above using the double-colon in place of zeros:

    1507:f0d0:1002:51::4

How IP addresses are stored in the database

The IP address ip_addr field is a Variable Character (VARCHAR) field with a length of 45 characters. The values are always stored in four-digit groupings in doc-decimal notation for both IPv4 or IPv6 addresses regardless of the notation you use when you input values in the field. For example:
  • If you enter an IPv6 IP address in an using double-colons, the value in the database is actually expanded to its full IP address without compression: 1507:f0d0:1002:51::4 is saved in the database as 1507:f0d0:1002:0051:0000:0000:0000:0004
  • If you enter an IPv4 address in hex notation, it is saved in the database as the standard dot-decimal notation: 0x0A223314 is saved as 10.34.51.20.

If you run a query on this field type in scripts, make sure to query on the full dot-decimal notation.