# urbestack-firewall-rule-add

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 command, run as root in the server shell.

## Usage

```
urbestack-firewall-rule-add --kind port|allow|deny|closed --value VALUE [--note TEXT] [--client ADDRESS]
```

## Description

Adds a firewall rule. Use --kind port to open an extra port or --kind closed to drop traffic to a port even if a service is listening. IP addresses on the Allow list can still reach a closed port. For either kind, --value accepts a port or an inclusive range such as 30000-31000. Port numbers run from 1 to 65535, and ranges start at the lower port. TCP is the default. Append /udp for UDP or /tcp to specify TCP explicitly.

For --kind allow or --kind deny, --value accepts an IPv4 or IPv6 address or a network in CIDR notation. Adding to the Allow list lifts any active bans it covers. An allow rule can make an exception inside a larger denied network. UrbeStack rejects a deny rule that an allow rule already covers in full, and an allow rule that would cover an existing deny rule in full. It also rejects duplicate rules.

Use --client to specify the caller's IP address. If omitted in an SSH session, the command uses the SSH client's IP address. UrbeStack refuses a deny rule that covers the caller's IP address, a server IP address, or loopback. It lets you close an SSH or web interface port only if the caller's IP address is on the Allow list.

Adding a deny rule requires that no other change be pending. By default, UrbeStack restores the previous rules after five minutes unless you confirm with urbestack-firewall-confirm or the Confirm button in the web interface. Open a new session to verify access before confirming.

## Same in the API

- [POST /security/firewall/rules](https://urbestack.com/docs/api/post-security-firewall-rules.md): Add a firewall rule

## Command family: firewall

- [urbestack-firewall-confirm](https://urbestack.com/docs/commands/urbestack-firewall-confirm.md): Confirms the pending firewall change and cancels its automatic revert.
- [urbestack-firewall-ports-set](https://urbestack.com/docs/commands/urbestack-firewall-ports-set.md): Replaces the firewall's list of extra open ports.
- [urbestack-firewall-render](https://urbestack.com/docs/commands/urbestack-firewall-render.md): Regenerates the nftables rules and the sshd drop-in from UrbeStack's settings, checks both configurations, and applies them.
- [urbestack-firewall-revert](https://urbestack.com/docs/commands/urbestack-firewall-revert.md): Reverts the pending firewall change immediately.
- [urbestack-firewall-rule-del](https://urbestack.com/docs/commands/urbestack-firewall-rule-del.md): Removes the firewall rule selected by --id.
- [urbestack-firewall-rule-list](https://urbestack.com/docs/commands/urbestack-firewall-rule-list.md): Lists UrbeStack's firewall rules and the ports and ranges the firewall is configured to open.
- [urbestack-firewall-status](https://urbestack.com/docs/commands/urbestack-firewall-status.md): Shows whether UrbeStack's firewall is enabled, which rules are configured, and which ports and ranges it is configured to open and why.
