Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Configuration Language Lock 1.0.2 Minor update available for module config_language_lock (1.0.2). Release: Canvas Override 1.0.1 Minor update available for module canvas_override (1.0.1). Release: Media Remote Image 8.x-1.2 Minor update available for module media_entity_remote_image (8.x-1.2). Release: IDNA Convert Service (punycode) 2.0.4 Minor update available for module idna (2.0.4). Release: Bootstrap Cloud 7.1.3 Minor update available for theme bootstrap_cloud (7.1.3). Release: Token Browser 1.0.2 Minor update available for module token_browser (1.0.2). Release: Varbase Project 11.0.8 Minor update available for module varbase_project (11.0.8). Release: Media Remote Image 2.0.0-beta1 First beta version released for module media_entity_remote_image (2.0.0-beta1). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Security Coverage: Module Scout Module module_scout now has official Drupal security advisory coverage.

IP address fields

268 sites Security covered Drupal 10–11
View on drupal.org

This module provides a field type for storing single IP addresses or IP ranges, supporting both IPv4 and IPv6. It allows for flexible input formats like CIDR notation and wildcards, and offers efficient storage and querying of IP data directly in the database for faster lookups.

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.

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Apr 2026
Latest release
4 months ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

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