---
title: "ezgh compute firewalls rules add"
description: "Add rules to a firewall."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh compute firewalls rules add

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh compute firewalls rules add <firewall> (-f rules.json | --direction d --protocol p [--ports 22|8000-8100] [--icmp-type t [--icmp-code c]] (--cidr c|--peer-firewall f) [--description d]) [flags]
```

Add one rule, from the flags, or 1 to 50 rules from -f (a file, or - for stdin: a JSON array of rules, or an object with "rules"; `ezgh compute firewalls create --help` shows a rule's shape). A rule the firewall already has is refused (rule_duplicate).

Part of [`ezgh compute firewalls rules`](/cli/reference/compute-firewalls-rules).

## Examples

```sh
ezgh compute firewalls rules add web --direction inbound --protocol tcp --ports 443 --cidr 0.0.0.0/0
ezgh compute firewalls rules add db --direction inbound --protocol tcp --ports 5432 --peer-firewall web
ezgh compute firewalls rules add web -f rules.json
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--cidr` | string |  | allow this IPv4 or IPv6 prefix, such as 0.0.0.0/0 |
| `--description` | string |  | what the rule is for |
| `--direction` | string |  | inbound or outbound |
| `-f`, `--file` | string |  | rules to add: a JSON file, or - for stdin |
| `--icmp-code` | int |  | with `--icmp-type`: the ICMP code; default every code |
| `--icmp-type` | int |  | icmp and icmpv6: the ICMP type; default every type |
| `--peer-database` | string |  | allow this database (dbi\_…) |
| `--peer-firewall` | string |  | allow the members of this firewall (ID, UUID or name) |
| `--peer-load-balancer` | string |  | allow this load balancer (lbr\_…) |
| `--peer-sandbox-subnet` | string |  | allow the sandboxes started in this subnet (sbn\_…) |
| `--ports` | string |  | tcp and udp: a port (22) or range (8000-8100); default every port |
| `--protocol` | string |  | tcp, udp, icmp, icmpv6, all, or an IANA protocol number |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/compute-firewalls-rules-add/index.mdx
