# Network › IP addresses › Edge Network Firewall API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Network product's sections: https://developers.eu.ovhcloud.com/reference/network/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 9 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/network/ip-addresses/edge-network-firewall.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/network/ip-addresses/edge-network-firewall.json?format=openapi3

## Operations

- `GET /ip/{ip}/firewall` — List firewalled IPs
- `GET /ip/{ip}/firewall/{ipOnFirewall}/rule` — List rules
- `GET /ip/{ip}/firewall/{ipOnFirewall}` — Get a firewalled IP
- `GET /ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}` — Get a rule
- `POST /ip/{ip}/firewall` — Create a firewalled IP
- `POST /ip/{ip}/firewall/{ipOnFirewall}/rule` — Create a rule
- `DELETE /ip/{ip}/firewall/{ipOnFirewall}` — Delete a firewalled IP
- `DELETE /ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}` — Delete a rule
- `PUT /ip/{ip}/firewall/{ipOnFirewall}` — Update a firewalled IP

## List firewalled IPs

`GET /1.0/ip/{ip}/firewall`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#get-ip-ip-firewall

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/get`

List firewalled IPs. Returns the addresses of the block added to the firewall, filterable by state or by whether the firewall is enabled.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `enabled` | query | boolean |  | Filter the value of enabled property (=) |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `state` | query | ip.FirewallStateEnum |  | Filter the value of state property (=) — one of `disableFirewallPending`, `enableFirewallPending`, `ok` |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ipv4[] | successful operation |

```json
[
  "192.0.2.0"
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ip/{ip}/firewall")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ip/{ip}/firewall");

print_r($result);
?>
```

## List rules

`GET /1.0/ip/{ip}/firewall/{ipOnFirewall}/rule`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#get-ip-ip-firewall-iponfirewall-rule

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/rule/get`

List rules. Returns the sequence numbers of the address's firewall rules, filterable by state: creationPending, ok or removalPending.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |
| `state` | query | ip.FirewallRuleStateEnum |  | Filter the value of state property (=) — one of `creationPending`, `ok`, `removalPending` |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | integer[] | successful operation |

```json
[
  0
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}/rule" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ip/{ip}/firewall/{ipOnFirewall}/rule")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ip/{ip}/firewall/{ipOnFirewall}/rule");

print_r($result);
?>
```

## Get a firewalled IP

`GET /1.0/ip/{ip}/firewall/{ipOnFirewall}`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#get-ip-ip-firewall-iponfirewall

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/get`

Get a firewalled IP. Returns whether the firewall is enabled on this address, and its state: ok, enableFirewallPending or disableFirewallPending.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ip.FirewallIp | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean |  |  |
| `ipOnFirewall` | ipv4 | read-only | IPv4 address (e.g., 192.0.2.0) |
| `state` | ip.FirewallStateEnum | read-only | Current state of your ip on firewall — one of `disableFirewallPending`, `enableFirewallPending`, `ok` |

```json
{
  "enabled": true,
  "ipOnFirewall": "192.0.2.0",
  "state": "disableFirewallPending"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ip/{ip}/firewall/{ipOnFirewall}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ip/{ip}/firewall/{ipOnFirewall}");

print_r($result);
?>
```

## Get a rule

`GET /1.0/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#get-ip-ip-firewall-iponfirewall-rule-sequence

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/rule/get`

Get a rule. Returns the rule's action, protocol, source, destination, ports, TCP options, fragments option, packet length and state.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |
| `sequence` | path | integer | yes |  |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ip.FirewallNetworkRule | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | ip.FirewallActionEnum | read-only | Action on this rule — one of `deny`, `permit` |
| `creationDate` | string (date-time) | read-only |  |
| `destination` | string | read-only | Destination ip for your rule |
| `destinationPort` | string | read-only | Destination port range for your rule. Only with TCP/UDP protocol |
| `fragments` | boolean | read-only | Fragments option |
| `l3PacketLength` | string | read-only | IP packet's total length |
| `protocol` | ip.FirewallProtocolEnum | read-only | Network protocol — one of `ah`, `esp`, `gre`, `icmp`, `ipv4`, `tcp`, `udp` |
| `rule` | string | read-only |  |
| `sequence` | integer | read-only |  |
| `source` | string | read-only | Source ip for your rule |
| `sourcePort` | string | read-only | Source port range for your rule. Only with TCP/UDP protocol |
| `state` | ip.FirewallRuleStateEnum | read-only | Current state of your rule — one of `creationPending`, `ok`, `removalPending` |
| `tcpOption` | string | read-only | TCP option on your rule |

```json
{
  "action": "deny",
  "creationDate": "2024-01-01T12:00:00Z",
  "destination": "string",
  "destinationPort": "string",
  "fragments": true,
  "l3PacketLength": "string",
  "protocol": "ah",
  "rule": "string",
  "sequence": 0,
  "source": "string",
  "sourcePort": "string",
  "state": "creationPending",
  "tcpOption": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}");

print_r($result);
?>
```

## Create a firewalled IP

`POST /1.0/ip/{ip}/firewall`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#post-ip-ip-firewall

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/create`

Create a firewalled IP. Adds one address of the block to the firewall. Turn it on with Update a firewalled IP.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `ipOnFirewall` | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |

```json
{
  "ipOnFirewall": "192.0.2.0"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ip.FirewallIp | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean |  |  |
| `ipOnFirewall` | ipv4 | read-only | IPv4 address (e.g., 192.0.2.0) |
| `state` | ip.FirewallStateEnum | read-only | Current state of your ip on firewall — one of `disableFirewallPending`, `enableFirewallPending`, `ok` |

```json
{
  "enabled": true,
  "ipOnFirewall": "192.0.2.0",
  "state": "disableFirewallPending"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: ipv4
result = client.post("/ip/{ip}/firewall",
	ipOnFirewall = None, #  (type: ipv4)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: ipv4
$result = $ovh->post("/ip/{ip}/firewall", array(
	ipOnFirewall => null, //  (type: ipv4)
));

print_r($result);
?>
```

## Create a rule

`POST /1.0/ip/{ip}/firewall/{ipOnFirewall}/rule`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#post-ip-ip-firewall-iponfirewall-rule

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/rule/create`

Create a rule. Adds a permit or deny rule at sequence 0 to 19, matching protocol, source, ports or TCP options.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |

### Request body (required)

Type: `object`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | ip.FirewallActionEnum | yes | Action on this rule — one of `deny`, `permit` |
| `destinationPort` | integer |  | Destination port for your rule. Only with TCP/UDP protocol |
| `destinationPortRange` | complexType.Range_long |  | Destination port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside destinationPort. |
| `destinationPortRange.from` | integer |  |  |
| `destinationPortRange.to` | integer |  |  |
| `l3PacketLength` | complexType.Range_long |  | IP packet's total length |
| `l3PacketLength.from` | integer |  |  |
| `l3PacketLength.to` | integer |  |  |
| `protocol` | ip.FirewallProtocolEnum | yes | Network protocol — one of `ah`, `esp`, `gre`, `icmp`, `ipv4`, `tcp`, `udp` |
| `sequence` | ip.FirewallSequenceRangeEnum | yes | Sequence number of your rule — one of `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, … |
| `source` | ipv4Block |  | Source ip for your rule. Any if not set |
| `sourcePort` | integer |  | Source port for your rule. Only with TCP/UDP protocol |
| `sourcePortRange` | complexType.Range_long |  | Source port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside sourcePort. |
| `sourcePortRange.from` | integer |  |  |
| `sourcePortRange.to` | integer |  |  |
| `tcpOption` | ip.FirewallOptionTCP |  | Option on your rule. Can only be used with TCP protocol |
| `tcpOption.fragments` | boolean |  | TCP fragments |
| `tcpOption.option` | ip.FirewallTCPOptionEnum |  | TCP option — one of `established`, `syn` |

```json
{
  "action": "deny",
  "destinationPort": 0,
  "destinationPortRange": {
    "from": 0,
    "to": 0
  },
  "l3PacketLength": {
    "from": 0,
    "to": 0
  },
  "protocol": "ah",
  "sequence": 0,
  "source": "192.0.2.0/24",
  "sourcePort": 0,
  "sourcePortRange": {
    "from": 0,
    "to": 0
  },
  "tcpOption": {
    "fragments": true,
    "option": "established"
  }
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ip.FirewallNetworkRule | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | ip.FirewallActionEnum | read-only | Action on this rule — one of `deny`, `permit` |
| `creationDate` | string (date-time) | read-only |  |
| `destination` | string | read-only | Destination ip for your rule |
| `destinationPort` | string | read-only | Destination port range for your rule. Only with TCP/UDP protocol |
| `fragments` | boolean | read-only | Fragments option |
| `l3PacketLength` | string | read-only | IP packet's total length |
| `protocol` | ip.FirewallProtocolEnum | read-only | Network protocol — one of `ah`, `esp`, `gre`, `icmp`, `ipv4`, `tcp`, `udp` |
| `rule` | string | read-only |  |
| `sequence` | integer | read-only |  |
| `source` | string | read-only | Source ip for your rule |
| `sourcePort` | string | read-only | Source port range for your rule. Only with TCP/UDP protocol |
| `state` | ip.FirewallRuleStateEnum | read-only | Current state of your rule — one of `creationPending`, `ok`, `removalPending` |
| `tcpOption` | string | read-only | TCP option on your rule |

```json
{
  "action": "deny",
  "creationDate": "2024-01-01T12:00:00Z",
  "destination": "string",
  "destinationPort": "string",
  "fragments": true,
  "l3PacketLength": "string",
  "protocol": "ah",
  "rule": "string",
  "sequence": 0,
  "source": "string",
  "sourcePort": "string",
  "state": "creationPending",
  "tcpOption": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}/rule" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.post("/ip/{ip}/firewall/{ipOnFirewall}/rule",
	action = None, # Action on this rule (type: ip.FirewallActionEnum)
	destinationPort = None, # Destination port for your rule. Only with TCP/UDP protocol (type: long, nullable)
	destinationPortRange = None, # Destination port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside destinationPort. (type: complexType.Range<long>, nullable)
	l3PacketLength = None, # IP packet's total length (type: complexType.Range<long>, nullable)
	protocol = None, # Network protocol (type: ip.FirewallProtocolEnum)
	sequence = None, # Sequence number of your rule (type: ip.FirewallSequenceRangeEnum)
	source = None, # Source ip for your rule. Any if not set (type: ipv4Block, nullable)
	sourcePort = None, # Source port for your rule. Only with TCP/UDP protocol (type: long, nullable)
	sourcePortRange = None, # Source port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside sourcePort. (type: complexType.Range<long>, nullable)
	tcpOption = None, # Option on your rule. Can only be used with TCP protocol (type: ip.FirewallOptionTCP, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->post("/ip/{ip}/firewall/{ipOnFirewall}/rule", array(
	action => null, // Action on this rule (type: ip.FirewallActionEnum)
	destinationPort => null, // Destination port for your rule. Only with TCP/UDP protocol (type: long, nullable)
	destinationPortRange => null, // Destination port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside destinationPort. (type: complexType.Range<long>, nullable)
	l3PacketLength => null, // IP packet's total length (type: complexType.Range<long>, nullable)
	protocol => null, // Network protocol (type: ip.FirewallProtocolEnum)
	sequence => null, // Sequence number of your rule (type: ip.FirewallSequenceRangeEnum)
	source => null, // Source ip for your rule. Any if not set (type: ipv4Block, nullable)
	sourcePort => null, // Source port for your rule. Only with TCP/UDP protocol (type: long, nullable)
	sourcePortRange => null, // Source port range for your rule. Only with TCP/UDP protocol. Cannot be set alongside sourcePort. (type: complexType.Range<long>, nullable)
	tcpOption => null, // Option on your rule. Can only be used with TCP protocol (type: ip.FirewallOptionTCP, nullable)
));

print_r($result);
?>
```

## Delete a firewalled IP

`DELETE /1.0/ip/{ip}/firewall/{ipOnFirewall}`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#delete-ip-ip-firewall-iponfirewall

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/delete`

Delete a firewalled IP. Removes the address of the block from the firewall, together with all the rules set on it.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | string | successful operation |

```json
"string"
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/ip/{ip}/firewall/{ipOnFirewall}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/ip/{ip}/firewall/{ipOnFirewall}");

print_r($result);
?>
```

## Delete a rule

`DELETE /1.0/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#delete-ip-ip-firewall-iponfirewall-rule-sequence

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/rule/delete`

Delete a rule. Removes the rule at this sequence from the address's firewall, and returns the deleted rule.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |
| `sequence` | path | integer | yes |  |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | ip.FirewallNetworkRule | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `action` | ip.FirewallActionEnum | read-only | Action on this rule — one of `deny`, `permit` |
| `creationDate` | string (date-time) | read-only |  |
| `destination` | string | read-only | Destination ip for your rule |
| `destinationPort` | string | read-only | Destination port range for your rule. Only with TCP/UDP protocol |
| `fragments` | boolean | read-only | Fragments option |
| `l3PacketLength` | string | read-only | IP packet's total length |
| `protocol` | ip.FirewallProtocolEnum | read-only | Network protocol — one of `ah`, `esp`, `gre`, `icmp`, `ipv4`, `tcp`, `udp` |
| `rule` | string | read-only |  |
| `sequence` | integer | read-only |  |
| `source` | string | read-only | Source ip for your rule |
| `sourcePort` | string | read-only | Source port range for your rule. Only with TCP/UDP protocol |
| `state` | ip.FirewallRuleStateEnum | read-only | Current state of your rule — one of `creationPending`, `ok`, `removalPending` |
| `tcpOption` | string | read-only | TCP option on your rule |

```json
{
  "action": "deny",
  "creationDate": "2024-01-01T12:00:00Z",
  "destination": "string",
  "destinationPort": "string",
  "fragments": true,
  "l3PacketLength": "string",
  "protocol": "ah",
  "rule": "string",
  "sequence": 0,
  "source": "string",
  "sourcePort": "string",
  "state": "creationPending",
  "tcpOption": "string"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/ip/{ip}/firewall/{ipOnFirewall}/rule/{sequence}");

print_r($result);
?>
```

## Update a firewalled IP

`PUT /1.0/ip/{ip}/firewall/{ipOnFirewall}`

Link: https://developers.eu.ovhcloud.com/reference/network/ip-addresses/edge-network-firewall/#put-ip-ip-firewall-iponfirewall

**Status:** Stable production version  
**IAM actions:** `ip:apiovh:firewall/edit`

Update a firewalled IP. Turns the firewall on or off for this address. Its state is enableFirewallPending or disableFirewallPending until the change is applied.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `ip` | path | ipBlock | yes | IP (v4 or v6) CIDR notation (e.g., 192.0.2.0/24) |
| `ipOnFirewall` | path | ipv4 | yes | IPv4 address (e.g., 192.0.2.0) |

### Request body (required)

Type: `ip.FirewallIp`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean |  |  |
| `ipOnFirewall` | ipv4 | read-only | IPv4 address (e.g., 192.0.2.0) |
| `state` | ip.FirewallStateEnum | read-only | Current state of your ip on firewall — one of `disableFirewallPending`, `enableFirewallPending`, `ok` |

```json
{
  "enabled": true
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/1.0/ip/{ip}/firewall/{ipOnFirewall}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: ip.FirewallIp
result = client.put("/ip/{ip}/firewall/{ipOnFirewall}",
	enabled = None, #  (type: boolean)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: ip.FirewallIp
$result = $ovh->put("/ip/{ip}/firewall/{ipOnFirewall}", array(
	enabled => null, //  (type: boolean)
));

print_r($result);
?>
```
