# ASN Lookup: IP to ASN, AS Name & Country in Bulk (`ucchiii/ip-asn-lookup`) Actor

ASN lookup in bulk for IPv4, IPv6 and domains: AS number, AS name, country and the announced IP range, from a bundled offline IPtoASN database (no lookup API). Domains are resolved over DNS-over-HTTPS. Up to 10,000 entries per run. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/ip-asn-lookup.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.25 / 1,000 ip address with asns

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**ASN Lookup: IP to ASN, AS name and country for lists of IPv4 / IPv6 addresses and domains**

**For anyone who needs to know which network an IP address belongs to, for many addresses at once:** security and fraud teams triaging logs, SOC analysts enriching alerts, network engineers, hosting and CDN researchers, brand-protection and domain investors checking where sites are hosted. Give this Actor up to 10,000 IP addresses or domains and get **one row per IP: AS number (ASN), AS name, country, and the IP range (start, end, CIDR) it belongs to**.
IPs are looked up in an **offline IPtoASN database built into the Actor**: no lookup API, no API key, no rate limits, results in seconds. Domains are first resolved to their A / AAAA addresses over DNS-over-HTTPS (Cloudflare 1.1.1.1).

**Try it free: leave input empty and press Start** (four sample IPs, not charged, rows carry `_demo: true`).

### Sample output

(Values from the fixture used in our tests; real runs show the current data.)

| input | ip | version | asn | asName | country | rangeStart | rangeEnd |
|---|---|---|---|---|---|---|---|
| 1.1.1.1 | 1.1.1.1 | 4 | 13335 | CLOUDFLARENET - Cloudflare, Inc. | US | 1.1.1.0 | 1.1.1.255 |
| 8.8.8.8 | 8.8.8.8 | 4 | 15169 | GOOGLE - Google LLC | US | 8.8.8.0 | 8.8.8.255 |
| example.com | 2001:db8::1 | 6 | 64510 | EXAMPLE-V6 Example IPv6 network | NL | 2001:db8:: | 2001:db8:0:ffff:ffff:ffff:ffff:ffff |
| 192.168.1.10 | 192.168.1.10 | 4 | | | | | |

### Pricing

**$0.35 per 1,000 IPs** ($0.00035 for each IP address found in the database). You pay only for IPs with a result: AS number, AS name, country and range returned. A domain costs the same as the IPs it resolves to that are found (example.com with one IPv4 and one IPv6 address = 2 IPs).
**Free:** invalid input, IPs not found (private, loopback, reserved, not routed), domains that do not exist or have no address, DNS failures, and the demo. Set a maximum charge per run to cap spend; the Actor stops cleanly when it is reached.
On the Apify Free plan, the $5 of monthly platform credit covers about **14,000 IPs** a month — enough to try it on real data.

### What it does

- **IPv4 and IPv6**: `1.1.1.1`, `2001:4860:4860::8888`, `[2001:db8::1]:443`, `1.1.1.1:443`, `https://1.1.1.1/` all work. IPv4-mapped IPv6 (`::ffff:8.8.8.8`) is looked up as IPv4.
- **Domains too**: `example.com` or `https://www.example.com/page` is resolved to its A (and, if you want, AAAA) addresses, and every address gets its own row (up to 10 per domain) with the domain in `input`.
- **AS number, AS name and country** of the range, plus `rangeStart`, `rangeEnd` and the range as CIDR blocks.
- **Clear "not found" rows**: private, loopback, link-local, multicast, reserved or unrouted addresses come back with `status: not_found` and a `note` saying why (free).
- **Offline and fast**: no external lookup API at run time, so no API keys, no third-party rate limits and nothing sent anywhere for IP entries. Only domains need one DNS question per record type.
- **Chains with other Actors**: point `datasetId` at a dataset of IPs or domains, e.g. the `a` list from DNS Records Lookup.

### Input example

```json
{
  "ips": ["1.1.1.1", "8.8.8.8", "2001:4860:4860::8888", "wikipedia.org"],
  "resolveIpv6": true
}
```

### Output

One row per IP address:

```json
{
  "input": "1.1.1.1",
  "ip": "1.1.1.1",
  "version": 4,
  "status": "ok",
  "asn": 13335,
  "asName": "CLOUDFLARENET - Cloudflare, Inc.",
  "country": "US",
  "rangeStart": "1.1.1.0",
  "rangeEnd": "1.1.1.255",
  "cidr": ["1.1.1.0/24"],
  "note": null,
  "source": "IPtoASN (iptoasn.com, ip2asn-combined)",
  "dbDate": "2026-11-01",
  "error": null,
  "checkedAt": "2026-11-08T09:00:00Z"
}
```

| status | meaning | charged |
|---|---|---|
| `ok` | the IP is in an announced range: ASN, AS name, country and range returned | yes |
| `not_found` | the IP is not in any announced range (`note`: private, loopback, reserved, not_routed ...) | no |
| `nxdomain` / `no_address` | the domain does not exist / has no A or AAAA record | no |
| `error` | invalid input (`invalid_input`) or the DNS lookup failed after retries (e.g. `a:dns_http_503`) | no |

The record `SUMMARY` in the key-value store counts each status, the charged IPs and the database date.

### Data source and freshness

The ASN data is the **IPtoASN** database (`ip2asn-combined.tsv`, by iptoasn.com), a public mapping of announced IP ranges to AS numbers. It is downloaded from its official URL each time the Actor is built, and every row carries the database date in `dbDate`. `country` is the country of the AS that announces the range as listed in that database; it is **not** a geolocation of the person or device using the IP.

### Use cases

- Enrich firewall, web server or sign-up logs with ASN and AS name (spot cloud and hosting providers)
- Find which cloud, CDN or hosting company serves a list of websites
- Group IPs by network operator for abuse reports or block lists
- Check where a domain portfolio, or a competitor's sites, are hosted

### Limits (cannot be raised by input)

- 10,000 entries per run, of which at most 1,000 domains; up to 10 addresses per domain
- DNS: up to 10 domains in parallel, at least 0.05 s between requests to the resolver, timeout per request (default 10 s), at most 3 tries
- The database reflects the routing table at its build date (`dbDate`); recently moved ranges may differ
- No city or ISP-level geolocation, no reverse DNS, no WHOIS of the IP owner

### FAQ

**Does it call an IP lookup API?** No. The lookup runs on the database inside the Actor. The only network request at run time is the DNS question for domain entries.
**Why is my IP `not_found`?** It is private, reserved, or not announced on the public internet in the database's snapshot. Not-found IPs are free.
**Can I look up a whole CIDR range?** Not yet: give single IP addresses. CIDR input comes back as `invalid_input` (free).
**Is `country` where the user is?** No. It is the country listed for the AS in IPtoASN, which often differs from where an IP is used.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [DNS Lookup](https://apify.com/ucchiii/dns-records-lookup) — bulk DNS lookup: A, AAAA, MX, NS, TXT, SPF and DMARC per domain
- [Website Technology Detector](https://apify.com/ucchiii/website-technology-detector) — tech stack of websites in bulk: CMS, frameworks, analytics and tag IDs, CDN, consent tools
- [Domain WHOIS & DNS Lookup](https://apify.com/ucchiii/domain-whois) — bulk WHOIS (RDAP) and DNS lookup: registrar, expiry, days left, A/MX/NS, no personal data
- [SSL Certificate Expiry Checker](https://apify.com/ucchiii/ssl-certificate-checker) — SSL/TLS certificate expiry dates, issuer and validity for many hosts, soonest first
- [Bulk URL Status Checker](https://apify.com/ucchiii/url-status-checker) — bulk HTTP status and redirect-chain checker for URL lists

# Actor input Schema

## `ips` (type: `array`):

One per entry: an IPv4 address ('8.8.8.8'), an IPv6 address ('2001:4860:4860::8888'), or a domain / URL ('example.com', 'https://www.example.com/page'). A domain is resolved to its A (and AAAA) addresses and gives one row per address (up to 10). Ports and brackets ('\[2001:db8::1]:443', '1.1.1.1:443') are removed. CIDR ranges such as '1.1.1.0/24' are not single IPs and come back as invalid (free). Duplicates are removed. Leave empty (and no dataset) to run a free demo. Up to 10,000 entries (at most 1,000 domains) per run.

## `datasetId` (type: `string`):

Optional. Dataset ID (a finished run's 'defaultDatasetId') whose items contain IP addresses or domains, for example the output of another Actor. Added to the list above. A field may hold one value or a list (such as the 'a' list of DNS Records Lookup). The 10,000-entry cap applies to the total.

## `ipField` (type: `string`):

Name of the field in each dataset item that holds the IP address or domain. Default 'ip'.

## `resolveIpv6` (type: `boolean`):

For domain entries, also ask for AAAA records and look up the IPv6 addresses. Off = IPv4 (A records) only. Has no effect on IP entries.

## `timeoutSecs` (type: `integer`):

Timeout for each DNS-over-HTTPS request (domains only), in seconds. Failed requests are retried up to 3 times with a growing pause. Allowed range 1 to 60 (default 10).

## `concurrency` (type: `integer`):

How many domains are resolved in parallel. Allowed range 1 to 10 (default 5), with at least 0.05 s between requests to the resolver. IP entries need no network and are not affected.

## Actor input object example

```json
{
  "ips": [
    "1.1.1.1",
    "8.8.8.8",
    "2001:4860:4860::8888",
    "wikipedia.org"
  ],
  "ipField": "ip",
  "resolveIpv6": true,
  "timeoutSecs": 10,
  "concurrency": 5
}
```

# Actor output Schema

## `results` (type: `string`):

One row per IP address (a domain gives one row per resolved address): asn, asName, country, rangeStart, rangeEnd, cidr, status, source and dbDate. Download as CSV, JSON, Excel and more from here.

## `summary` (type: `string`):

Record SUMMARY: entries, domains, rows per status, charged IPs, duplicates removed, entries over the limit, database date.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "ips": [
        "1.1.1.1",
        "8.8.8.8",
        "2001:4860:4860::8888",
        "wikipedia.org"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/ip-asn-lookup").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "ips": [
        "1.1.1.1",
        "8.8.8.8",
        "2001:4860:4860::8888",
        "wikipedia.org",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/ip-asn-lookup").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "ips": [
    "1.1.1.1",
    "8.8.8.8",
    "2001:4860:4860::8888",
    "wikipedia.org"
  ]
}' |
apify call ucchiii/ip-asn-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/ip-asn-lookup"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/dganTB5KW8qjLom9w/builds/8Gw8puCJLTsQqaxLp/openapi.json
