# IP in CIDR: Is This Address in That Block?

Check which IPs or CIDR blocks fall inside which blocks, and whether two lists of blocks overlap. items: addresses (or blocks), one per line, about 3,000 on the server; cidrs: the blocks to check against, up to 1,000, optionally named with "name: block". For each item returns the blocks that contain it, most specific first (or none, with the nearest block), and for blocks in both lists the overlaps (equal, inside, or partial) with the shared range and address count. IPv4 and IPv6, any mix; a family with no block to compare is not an error. Lines that cannot be read are returned with the reason. No network lookups.

**Not for:** Finding who owns an address (use ip_whois or asn_lookup).

- Tool id: `cidr-contains`
- Category: ip
- Execution: pure
- MCP tool `cidr_contains` at https://lookupowl.com/mcp
- REST `GET https://lookupowl.com/api/v1/tools/cidr-contains` (or POST a JSON body)
- OpenAPI: https://lookupowl.com/api/openapi.json

## Input

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `items` | string | yes |  | IP addresses (or blocks), one per line, up to about 40,000 characters (roughly 3,000 lines; the web page takes more in your browser). An address is checked against the blocks; a block is checked for overlap with them. max length 40000 |
| `cidrs` | string | no | `""` | The blocks to check against, one per line, up to 1,000. Give a block a name with "name: block" and the name is used in the answer. max length 20000 |
| `showNoMatch` | boolean | no | `true` | Also list the addresses that matched no block. |

## Output

Results are wrapped in an envelope: `tool`, `version`, `requestId`, `data`, `summary`, `meta` (cache status, timing), `permalink`. `data` has these fields:

| Field | Type | Description |
|---|---|---|
| `mode` | "contains" \| "overlap" |  |
| `items` | object[] |  |
| `overlaps` | object[] |  |
| `summary` | object |  |
| `ignored` | object[] |  |

## Examples

### Which block holds each address

```json
{"items":"203.0.113.77\n10.1.2.3\n198.51.100.9\n2001:db8:abcd::1","cidrs":"office: 203.0.113.0/24\ncorp: 10.0.0.0/8\nlab: 10.1.0.0/16\nv6: 2001:db8::/32","showNoMatch":true}
```

```bash
curl 'https://lookupowl.com/api/v1/tools/cidr-contains?cidrs=office%3A+203.0.113.0%2F24%0Acorp%3A+10.0.0.0%2F8%0Alab%3A+10.1.0.0%2F16%0Av6%3A+2001%3Adb8%3A%3A%2F32&items=203.0.113.77%0A10.1.2.3%0A198.51.100.9%0A2001%3Adb8%3Aabcd%3A%3A1&showNoMatch=true'
```

Web page: https://lookupowl.com/ip-in-cidr?q=203.0.113.77%0A10.1.2.3%0A198.51.100.9%0A2001%3Adb8%3Aabcd%3A%3A1&cidrs=office%3A+203.0.113.0%2F24%0Acorp%3A+10.0.0.0%2F8%0Alab%3A+10.1.0.0%2F16%0Av6%3A+2001%3Adb8%3A%3A%2F32

### Do two sets of VPC blocks overlap

```json
{"items":"10.0.0.0/16\n172.16.0.0/12","cidrs":"10.0.128.0/17\n192.168.0.0/16","showNoMatch":true}
```

```bash
curl 'https://lookupowl.com/api/v1/tools/cidr-contains?cidrs=10.0.128.0%2F17%0A192.168.0.0%2F16&items=10.0.0.0%2F16%0A172.16.0.0%2F12&showNoMatch=true'
```

Web page: https://lookupowl.com/ip-in-cidr?q=10.0.0.0%2F16%0A172.16.0.0%2F12&cidrs=10.0.128.0%2F17%0A192.168.0.0%2F16

## Web pages

- https://lookupowl.com/ip-in-cidr

## Limits and caching

- Cost: 1 unit for a live lookup, 1 unit for a cached one. Budgets are per network and published in the `RateLimit` response headers.
- Cache: results are kept for 86400 s.
- Timeout: 5 s.

## Related tools

- [CIDR Aggregator: Merge IPs and Ranges into CIDR Blocks](https://lookupowl.com/tools/cidr-aggregate.md): Merge a messy list of IPs, ranges and CIDRs into the fewest exact CIDR blocks, with optional exclusions and firewall-ready exports.
- [VLSM Subnet Planner: Split a Network into Subnets](https://lookupowl.com/tools/subnet-plan.md): Split a network into equal subnets or right-sized VLSM subnets for named host counts, and see what is left.
- [IP Subnet Calculator](https://lookupowl.com/tools/subnet-calculator.md): Network, broadcast, usable range, masks and exact host counts for any IPv4 or IPv6 subnet.
- [CIDR / IP Range Converter](https://lookupowl.com/tools/ip-range-convert.md): Turn CIDR blocks into first/last addresses, and IP ranges into the minimal list of CIDR blocks.
- [IP Location Lookup](https://lookupowl.com/tools/ip-location.md): Where an IP address is: city, region, country and the network that runs it, from DB-IP, with an honest accuracy note.

## Guide: IP in CIDR and overlap checker

Find out which addresses fall inside which blocks, and whether two lists of networks overlap before you peer or route them.

### Two questions in one page

The first question is "is this address in that block?" Paste one address and one block and you get a plain answer, with a bar that shows where the address sits between the first and last address of the block. Paste many addresses and many blocks and you get a table: each address, the most specific block that holds it, and any larger blocks around that one.

The second question is "do these networks overlap?" Put one list of networks in the first box and another list in the blocks box. For every pair that shares addresses, the page names the shared range, counts the addresses, and draws both blocks on one address axis so you can see which one sits inside which.

### How to use it

1. **List what you want to check**: Put addresses, or blocks, in the first box, one per line. Single addresses are looked up. Blocks, ranges and masks are compared for overlap.
2. **List the blocks to check against**: Add `203.0.113.0/24` or a name before a colon, such as `office: 203.0.113.0/24`. The name then appears in the answer instead of the number.
3. **Read the answer**: An address in several blocks shows the most specific one first, because the smallest block is the one a router would pick. An address in none shows the nearest block you gave.

### Checking for overlap before peering

Two networks that share addresses cannot be routed to each other without a clash. Cloud VPC peering, VPN links and company mergers all hit this. List your networks in one box and theirs in the other. If nothing overlaps, you can go ahead. If something does, you see which blocks clash and by how many addresses, which tells you how much renumbering the fix needs.

> **What no overlap does not prove** The check compares address ranges only. It does not know your route tables, security groups or firewall rules, so a clean result means the addresses are free to use, not that traffic will flow.

| Relation | Meaning | Example |
|---|---|---|
| Equal | Both blocks hold the same addresses | `10.0.0.0/16` and `10.0.0.0/16` |
| Inside | One block is wholly inside the other | `10.0.128.0/17` inside `10.0.0.0/16` |
| Partial | They share some addresses, each has more | Ranges `10.0.0.0-10.0.0.200` and `10.0.0.100-10.0.0.255` |
| None | They share no address | `172.16.0.0/12` and `192.168.0.0/16` |

### Doing the same in code

The result page has a tab with the same check in Python, PostgreSQL and JavaScript for the values you entered. In Python, `ipaddress.ip_address(x) in ipaddress.ip_network(block)` does it. In PostgreSQL, `inet << cidr` does it, and the index on a `cidr` column makes it fast. An AI agent can call the `cidr_contains` tool through MCP for the same answer.

### Where your lists go

With JavaScript on, the lists are compared in your browser and nothing you paste is sent to us. Without JavaScript the form sends them to our server in the page address, so keep them short there. The browser accepts up to 10,000 addresses against 1,000 blocks; the server takes about 3,000 addresses. See the [privacy policy](https://lookupowl.com/privacy) for the rest.

### Frequently asked questions

**How do I check whether an IP is in a CIDR range?**

Put the address in the first box and the block in the second, then press Check. The answer says whether the address is inside, which address of the block it is, and the first and last address of the block.

**What does most specific block first mean?**

Blocks can sit inside each other: a /8 holds a /16 which holds a /24. When an address is in several, the one with the longest prefix is listed first because that is the route a router prefers.

**Can I name my blocks?**

Yes. Write `name: block` on a line, for example `lab: 10.1.0.0/16`. The name is used in the answer and in the table.

**Does it work for IPv6?**

Yes. IPv4 and IPv6 can be mixed in one list. An address is only compared with blocks of its own family, and if you gave no block of that family the page says so instead of reporting an error.

**What happens when an address is in no block?**

It is listed as not in any block, with the nearest block you gave, so you can see how close it was. That is a normal answer, not an error.

**Can I compare two lists of networks?**

Yes. Put networks, not single addresses, in the first box. Every pair that shares addresses is listed with the shared range, the number of addresses and a drawing of both blocks.
