REFERENCE

v6.11.0

Routing Rules

Policy routing rules selecting a table by src/dst/interface/mark (`/routing rule`).

Tools

list_routing_rules

List Policy Routing Rules · Risk: read

List policy routing rules (/routing rule) — the ordered table that steers packets into specific routing tables based on src/dst prefix, incoming interface, or routing-mark. Rules are evaluated top-down; requires RouterOS v7 with the routing package. For static routes in the main table use list_routes; for IPv6 static routes use list_ipv6_routes. Returns all matching rules with full detail, including .id values needed by get_routing_rule, update_routing_rule, remove_routing_rule, and set_routing_rule_enabled.

ParameterRequiredDefinition
table_filterNoMatch rules targeting this table {"type":"string"}
disabled_onlyYes{"default":false,"type":"boolean"}

get_routing_rule

Get Policy Routing Rule · Risk: read

Fetch full detail for a single policy routing rule (/routing rule) by its .id (obtain the .id from list_routing_rules). Requires RouterOS v7 with the routing package. For static route details use get_route. Returns the rule's complete property set, or a not-found message if the id does not exist.

ParameterRequiredDefinition
rule_idYesRule id from list output, e.g. "*3" {"type":"string"}

add_routing_rule

Add Policy Routing Rule · Risk: write

Add a policy routing rule (/routing rule add) to steer matched packets into a specific routing table. Rules are evaluated top-down: action=lookup consults table then falls through to lower-priority tables on no match; lookup-only-in-table stops at that table; drop/unreachable discard the packet. Match on src_address (e.g. "192.168.10.0/24"), dst_address, routing_mark, or incoming interface. Use place_before with a rule .id to control insertion order. Requires RouterOS v7 with the routing package. For static routes in the main or a named table use add_route; for IPv6 static routes use add_ipv6_route. Returns the new rule's .id.

ParameterRequiredDefinition
actionYes{"default":"lookup","type":"string","enum":["lookup","lookup-only-in-table","drop","unreachable"]}
tableNoTarget routing table for lookup actions {"type":"string"}
src_addressNoSource prefix, e.g. "192.168.10.0/24" {"type":"string"}
dst_addressNoDestination prefix {"type":"string"}
routing_markNoMatch packets carrying this routing-mark {"type":"string"}
interfaceNoMatch this incoming interface {"type":"string"}
min_prefixNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
commentNo{"type":"string"}
disabledYes{"default":false,"type":"boolean"}
place_beforeNoInsert before this rule id to control ordering {"type":"string"}

update_routing_rule

Update Policy Routing Rule · Risk: write-idempotent

Modify an existing policy routing rule (/routing rule set) by its .id (obtain from list_routing_rules). Pass "" for src_address, dst_address, routing_mark, interface, or table to clear that field. Requires RouterOS v7 with the routing package. For updating static routes use update_route. Returns the rule's updated detail after applying changes.

ParameterRequiredDefinition
rule_idYesRule id, e.g. "*3" {"type":"string"}
actionNo{"type":"string","enum":["lookup","lookup-only-in-table","drop","unreachable"]}
tableNo{"type":"string"}
src_addressNo{"type":"string"}
dst_addressNo{"type":"string"}
routing_markNo{"type":"string"}
interfaceNo{"type":"string"}
min_prefixNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
commentNo{"type":"string"}
disabledNo{"type":"boolean"}

remove_routing_rule

Remove Policy Routing Rule · Risk: destructive

Delete a policy routing rule (/routing rule remove) by its .id (obtain from list_routing_rules). This is irreversible — confirm the correct rule with get_routing_rule before removing. Requires RouterOS v7 with the routing package. For removing static routes use remove_route. Returns a confirmation message on success.

ParameterRequiredDefinition
rule_idYesRule id, e.g. "*3" {"type":"string"}

set_routing_rule_enabled

Enable or Disable Policy Routing Rule · Risk: write-idempotent

Enable or disable a policy routing rule (/routing rule set disabled=yes/no) by its .id (obtain from list_routing_rules). Set enabled=true to activate or enabled=false to temporarily suspend the rule without deleting it. Requires RouterOS v7 with the routing package. To permanently delete a rule use remove_routing_rule. Returns a confirmation of the new enabled/disabled state.

ParameterRequiredDefinition
rule_idYesRule id, e.g. "*3" {"type":"string"}
enabledYestrue to enable, false to disable {"type":"boolean"}

On this page