> 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/xql-command-reference-guide/readme/functions/is_ipv4.md).

# is\_ipv4

Use the `is_ipv4()` function to determine if a string value represents a valid IPv4 address.

## Syntax

```sql
is_ipv4(<string>)
```

## Parameters

| Name     | Type   | Required | Description                                                      |
| -------- | ------ | -------- | ---------------------------------------------------------------- |
| `string` | string | Yes      | The string field or literal value to evaluate for IPv4 validity. |

## Returns

The `is_ipv4()` function returns a boolean value: true if the string is a valid IPv4 address, and false otherwise.

## Usage Notes

The function expects a string input and will return NULL if the input field is NULL.

Validation is strictly for IPv4 dotted-decimal format (for example, "192.168.1.1").

This function is typically used within the `alter` stage to tag records or within the filter stage to isolate specific traffic types.

## Examples

### Example 1: Validate IPv4 Addresses in a Dataset

**Goal**: Identify which records in the dataset contain a valid IPv4 address in the ipv4\_address field.

**XQL Code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| alter valid_ip = is_ipv4(ipv4_address)
| fields event_id, ipv4_address, valid_ip
| limit 3
```

**Explanation**: You use the is\_ipv4() function to check the `ipv4_address` field. For record 101, the `is_ipv4()` function returns true because "192.168.1.10" is a valid IPv4 address. For record 103, where the field is NULL, the `is_ipv4()` function returns NULL.

**Output**:

| EVENT\_ID | IPV4\_ADDRESS | VALID\_IP |
| --------- | ------------- | --------- |
| 101       | 192.168.1.10  | true      |
| 102       | 10.0.0.5      | true      |
| 103       | NULL          | NULL      |

### Example 2: Filtering for Valid IPv4 Traffic

**Goal**: Filter the result set to return only those records that have a valid IPv4 address.

**XQL Code**:

```sql
config timeframe = 1d
| dataset = sample_xql_raw
| filter is_ipv4(ipv4_address) = true
| fields event_id, ipv4_address
| limit 2
```

**Explanation**: You apply the `is_ipv4()` function directly within a filter stage to exclude any records where the ipv4\_address field does not contain a properly formatted IPv4 address.

**Output**:

| EVENT\_ID | IPV4\_ADDRESS |
| --------- | ------------- |
| 101       | 192.168.1.10  |
| 102       | 10.0.0.5      |

## Related Articles

* **Stages**: [alter](/xql-command-reference-guide/readme/stages/alter.md), [filter](/xql-command-reference-guide/readme/stages/filter.md), [fields](/xql-command-reference-guide/readme/stages/fields.md), [limit](/xql-command-reference-guide/readme/stages/limit.md)
* **Functions**: [incidr()](/xql-command-reference-guide/readme/functions/incidr.md), [int\_to\_ip()](/xql-command-reference-guide/readme/functions/int_to_ip.md), [ip\_to\_int()](/xql-command-reference-guide/readme/functions/ip_to_int.md)


---

# 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/xql-command-reference-guide/readme/functions/is_ipv4.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.
