Drupal is a registered trademark of Dries Buytaert
cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)!

field_ipaddress

270 sites Security covered
View on drupal.org

Provides a field type for storing single IP addresses or IP ranges, in either IPv4 or IPv6. Values are stored as a [start, end] pair in indexed binary columns, so range-membership queries run natively in SQL against the field's index rather than in PHP.

Accepted input

A single text field accepts any of these forms and normalises them to an internal [start, end] pair:

  • A single IP — 10.10.10.10 or 2001:db8::1
  • A dash range — 10.10.10.0 - 10.10.12.255 (whitespace ignored)
  • A partial IPv4 range (last octet only) — 10.10.10.10-20 becomes 10.10.10.10-10.10.10.20
  • Wildcards, any number of asterisks — 10.10.*.*, 2001:db8::*:*
  • CIDR notation — 10.10.10.0/24, 2001:db8::/32

Invalid input is rejected inline by the widget, and as an HTTP 422 Unprocessable Entity response by the REST / JSON:API endpoints, with the offending input echoed back in the error message.

Per-field settings

  • IP version — restrict to IPv4, IPv6, or allow both.
  • Allow ranges — toggle whether the field accepts a range or only a single IP.
  • Allowed range — optionally limit accepted values to a specific sub-range, configured independently per family.

Views integration

Field values are exposed to Views with native sort and filter handlers. The filter supports =, !=, <, <=, >, >=, BETWEEN, and NOT BETWEEN. Range-to-range comparisons are correct on both sides — e.g. "all entities whose stored range overlaps 10.0.0.0/8" is one filter operator, not a custom query.

Drupal 7 migration

The module ships a migrate field plugin that maps the D7 field_ipaddress field type onto the current storage. Old ip2long() BIGINT columns are converted to the current binary
representation; D7's convention of end = 0 meaning "single IP" is recognised and migrates cleanly.

For developers

A helper service, field_ipaddress.iptools, exposes the two query patterns the field is designed for without requiring callers to hand-roll the binary encoding:

$iptools = \Drupal::service('field_ipaddress.iptools');

  // Entities whose stored range contains a single IP.
  $nids = $iptools->containsIp('node', 'field_ip', \Drupal::request()->getClientIp());

  // Entities whose stored range overlaps a given range.
  $nids = $iptools->overlapsRange('node', 'field_ip', '10.0.0.0/24');
  

Both methods accept a string, an ip2long() integer, or a pre-parsed \Drupal\field_ipaddress\IpAddress object. Entity access checks are on by default.

Compatibility

Drupal 10, 11, and 12. On Drupal 10 / 11.0 / 11.1 the Views integration transparently falls back to the pre-11.2 procedural helper — no action required.

Activity

Total releases
4
First release
Apr 2026
Latest release
1 month ago
Release cadence
0 days
Stability
75% stable

Release Timeline

Releases

Version Type Release date
2.1.3 Stable Apr 24, 2026
2.1.x-dev Dev Apr 24, 2026
2.1.1 Stable Apr 24, 2026
2.1.0 Stable Apr 24, 2026