> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/cortex-xdr-3.x/cortex-xdr-3.x-documentation/cortex-xdr-xql/functions/incidr.md).

# incidr

**Syntax**

```programlisting
incidr(<IPv4_address>, <CIDR1_range1> | <CIDR1_range1, CIDR2_range2, ...>)
```

**Description**

The `incidr()` function accepts an IPv4 address, and an IPv4 range or comma separated IPv4 ranges using CIDR notation, and returns `true` if the address is in range. Both the IPv4 address and CIDR ranges can be either an explicit string using quotes (`""`), such as `"192.168.0.1"`, or a string field.

{% hint style="info" %}

### Note

The first parameter must contain an IPv4 address contained in an IPv4 field. For production purposes, this IPv4 address will normally be carried in a field that you retrieve from a dataset. For manual usage, assign the IPv4 address to a field, and then use that field with this function.
{% endhint %}

Multiple CIDRs are defined with comma separated syntax when building an XQL query with the Query Builder or in Correlation Rules. When defining multiple CIDRs, the logical `OR` is used between the CIDRS listed, so as long as one address is in range the entire statement returns `true`. Here are a few examples of how this logic works to determine whether the `incidr()` function returns `true` and displays results or `false`, where no results are displayed:

* Function returns `true` and results are displayed:

  ```programlisting
  dataset = test 
  | alter ip_address = "192.168.0.1" 
  | filter incidr(ip_address, "192.168.0.0/24, 1.168.0.0/24") = true
  ```
* Function returns `false` and no results are displayed:

  ```programlisting
  dataset = test 
  | alter ip_address = "192.168.0.1" 
  | filter incidr(ip_address, "2.168.0.0/24, 1.168.0.0/24") = true
  ```
* Function returns `false` and no results are displayed:

  ```programlisting
  dataset = test 
  | alter ip_address = "192.168.0.1" 
  | filter incidr(ip_address, "192.168.0.0/24, 1.168.0.0/24") = false
  ```
* Function returns `true` and results are displayed:

  ```programlisting
  dataset = test 
  | alter ip_address = "192.168.0.1" 
  | filter incidr(ip_address, "2.168.0.0/24, 1.168.0.0/24") = false
  ```

{% hint style="info" %}

### Note

The same logic is used when using the `incidr` and `not incidr` operators. For more information, see [Supported operators](/cortex-xdr-3.x/cortex-xdr-3.x-documentation/cortex-xdr-xql/get-started-with-xql/supported-operators.md).
{% endhint %}

**Examples**

Return a maximum of 10 `xdr_data` records, if the IPV4 address (`192.168.10.14`) is in range by verifying against a single CIDR (`192.168.10.0/24`):

```programlisting
alter my_ip = "192.168.10.14"
| alter inrange = incidr(my_ip, "192.168.10.0/24")
| fields inrange
| limit 10
      
```

Return a maximum of 10 `xdr_data` records, if the IPV4 address (`192.168.0.1`) is in range by verifying against multiple CIDRs (`192.168.0.0/24` or `1.168.0.0/24`):

```programlisting
dataset = xdr_data 
| alter ip_address = "192.168.0.1" 
| filter incidr(ip_address, "192.168.0.0/24, 1.168.0.0/24") = true 
| limit 10
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/cortex-xdr-3.x/cortex-xdr-3.x-documentation/cortex-xdr-xql/functions/incidr.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
