opn_add_nat_rule
Create a NAT port forwarding rule to map an external destination port to an internal target IP and port, with configurable protocol and interface.
Instructions
Create a NAT port forwarding rule with savepoint protection where supported.
Use this when you need to forward an external port to an internal host. Savepoint protection applies on OPNsense < 26.7 only: there changes auto-revert in 60 seconds unless confirmed with opn_confirm_changes. OPNsense 26.7 removed the savepoint API upstream, so on 26.7+ changes apply immediately and are NOT rolled back automatically. Check opn_mcp_info first: if 'savepoint_support' is false, take a config backup with opn_download_config before changing rules that could lock you out.
Parameters:
destination_port: external port to forward (e.g. '8080', '3000-3010') — required
target_ip: internal IP address to forward to (e.g. '192.168.1.100') — required
interface: source interface (default 'wan')
protocol: 'TCP', 'UDP', or 'TCP/UDP' (default 'TCP')
target_port: internal port (default: same as destination_port)
description: human-readable description
Returns: dict with 'revision' (str), 'uuid' (str), and 'result' (str).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| protocol | No | TCP | |
| interface | No | wan | |
| target_ip | No | ||
| description | No | ||
| target_port | No | ||
| destination_port | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||