IP2Location is a non-intrusive IP geolocation solution that identifies a visitor's geographical location and network intelligence without invading user privacy. By leveraging a proprietary IP lookup database, this module provides granular insights ranging from basic country details to advanced ASN and infrastructure data.
As the official provider of IP2Location, we have been pioneers in the IP geolocation industry since 2002. We also maintain IP2Location LITE, a free database version that allows Drupal users to easily integrate geolocation capabilities into their websites at no cost.
Our latest update extends full support to the IP2Location DB26 Database, the most comprehensive binary database available. This update introduces mission-critical network intelligence fields, including District and ASN, enabling more precise regional targeting and security filtering.
Features
This plugin provides robust access to the IP2Location BIN database, supporting the following data points:
- Country (Name and ISO Code)
- Region (State/Province)
- District (County/District)
- City
- Latitude & Longitude
- ZIP / Postal Code
- Time Zone
- Connection Speed (Net Speed)
- ISP / Company Name
- Domain Name
- IDD Country Code
- Area Code
- Weather Station Code and Name
- Mobile Carrier (MCC, MNC, and Brand)
- Elevation (Meters above sea level)
- Usage Type (e.g., Commercial, Data Center, Mobile ISP)
- Address Type (Anycast, Unicast, Multicast, Broadcast)
- IAB Category (Content Taxonomy for advertising and filtering)
- ASN (Autonomous System Number)
- AS / AS Domain / AS CIDR (Autonomous System Name and Routing Details)
Installation
- Unzip the package into your
/modulesdirectory. - In your Drupal root directory, run the following command to install the required library:
composer require ip2location/ip2location-php - Navigate to Administer → Extend.
- Locate IP2Location in the module list, enable it, and save.
- Navigate to Configuration → IP2Location Settings.
- Provide the absolute path to your IP2Location BIN database file (e.g.,
/var/www/data/IP2LOCATION-DB26.BIN) and save the configuration.
Developer Usage
To retrieve geolocation data within other Drupal modules or themes, use the ip2location_get_records($ip_address) function. This function returns an object containing the geolocation data or null if no records are found.
$records = ip2location_get_records('8.8.8.8');
if ($records) {
$city = $records->city_name;
$district = $records->district; // New: Available with DB26
$asn = $records->asn; // New: Available with DB26
$as_name = $records->as; // New: Available with DB26
}Similar projects and how they are different
- Smart IP : smart_ip combines multiple ip geolocation solution providers into a single module. As we are owner from IP2Location, we could always ensure the IP2Location module issues are properly handled and updated as according to our latest release.
- IPtoLocation : IP2Location module provide additional feature, such as IPv6 database query and more information returns such as ZIP codes, connection speed, ISP, domain name, IDD country code, area code, weather station code and name, mobile carrier, elevation, and usage type.
- IP-based Determination of a Visitor's Country : ip2county provide the country information of an IP address. IP2Location module provides more information return as displayed on the overview section.
- Hostip : hostip provides the country, city and latitude & longitude information for profile display. IP2Location offers user a core library with more location information for user development.
- Location : location using HTML5 geolocation. IP2Location module use IP database and provides more information return as displayed on the overview section.
Project information
- Project categories: Site structure
36 sites report using this module
- Created by seikan on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.

