jacyimp / cloud-ip-detector
Detect which known cloud or infrastructure provider owns an IP address.
Requires
- php: ^8.2
Requires (Dev)
- infection/infection: ^0.31
- phpbench/phpbench: ^1.7
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- squizlabs/php_codesniffer: ^3.13
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Identify known provider and service networks behind an IP address.
Detection is fully offline using bundled IP range data.
Installation
composer require jacyimp/cloud-ip-detector
Usage
use JacyImp\CloudIpDetector\CloudIpDetector; use JacyImp\CloudIpDetector\Provider; $detector = new CloudIpDetector(); $detector->detectOne('104.16.10.20'); // Provider::Cloudflare
Unknown IPs return null:
$detector->detectOne('192.0.2.1'); // null
Multiple providers
Some IP ranges belong to more than one provider or service.
$detector->detectAll('1.178.4.1'); // [ // Provider::Aws, // Provider::HerokuAws, // ]
Check membership directly:
$detector->belongsTo('1.178.4.1', Provider::Aws); // true
detectOne() returns the most specific match. Ties are resolved deterministically by provider identifier.
Dependency Injection
Depend on CloudIpDetectorInterface when injecting the detector.
use JacyImp\CloudIpDetector\CloudIpDetectorInterface; final class RequestClassifier { public function __construct( private readonly CloudIpDetectorInterface $detector, ) { } }
Providers
All active providers from disposable/cloud-ip-ranges are supported.
Current provider coverage includes:
A2 Hosting, Adyen, Ahrefs, Akamai, Alibaba, Apple Private Relay, Aruba Cloud, Atlassian, AWS, Backblaze, Bing Bot, Branch, Bunny CDN, Bunny Magic Containers, Choopa, CircleCI, Cisco Webex, Cloudflare, Cyso Cloud, Datadog, DigitalOcean, DreamHost, Equinix Metal, Exoscale, Fastly, Fly.io, Gcore CDN, Gcore Cloud, GitHub, GitLab, GoDaddy, Google Bot, Google Cloud, Grafana Cloud, Gridscale, HCP Terraform, Heroku AWS, Hetzner, Huawei Cloud, Infomaniak, Intercom, IONOS Cloud, Kamatera, Linode, Meta Crawler, Microsoft 365, Microsoft Azure, New Relic Synthetics, nForce, Okta, Online SAS, OpenAI, Open Telekom Cloud, Oracle Cloud, OVH, PagerDuty, Perplexity, Rackspace, Render, Salesforce Hyperforce, Scaleway, Seeweb, Sentry, SoftLayer IBM, Stripe, Telegram, Tencent, UCloud, UpCloud, Vercel, Vultr, Wasabi, Yandex, Yandex Cloud, Zendesk, and Zscaler.
Provider::cases() is the definitive supported-provider list.
IP Range Data
Ranges are sourced from:
https://raw.githubusercontent.com/disposable/cloud-ip-ranges/refs/heads/master/csv/all-providers.csv
Only rows with an empty RetiredAt value are included.
The upstream dataset combines official provider ranges with ASN/BGP-derived and third-party sources.
No network requests are performed during detection.
Refresh the bundled snapshot with:
composer update:ranges
Invalid IP Addresses
Invalid IP addresses passed to any lookup method throw InvalidIpAddressException.
Performance
PHPBench on PHP 8.5.10 with OPcache and Xdebug disabled.
| Lookup | Time |
|---|---|
| Cloudflare hit | 0.002787 ms |
| AWS hit | 0.008180 ms |
| Unknown IP | 0.001207 ms |
| Multi-provider hit | 0.004009 ms |
Development
composer check composer infection composer bench
License
MIT