Set port forwarding rule
set_port_forwardingCreate or update a port forwarding rule on Keenetic routers using external port and target MAC or registered host IP, with dry-run default to preview changes before applying.
Instructions
Create or update a port forwarding rule ('ip static'). The target is addressed by MAC: pass to_host as a MAC, or as an IP that belongs to a registered host (it is resolved, and refused if unknown). dry_run is TRUE by default - it returns the payload without sending it. A real write is saved to startup-config and verified by re-reading the tree. Protected ports (this server's own and MCP_PROTECTED_PORTS) are refused in code.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"port": "<port>",
"to_host": "<to_host>"
},
"name": "set_port_forwarding"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | Yes | External port | |
| enable | No | false disables the rule (per-rule flag) | |
| comment | No | Rule comment | |
| dry_run | No | Default true | |
| to_host | Yes | Target MAC, or IP of a registered host | |
| to_port | No | Internal port, if different | |
| end_port | No | End of external port range | |
| protocol | No | tcp (default) or udp | |
| interface | No | WAN interface, default GigabitEthernet1 |