Skip to content

WinBox Native GUI syntax

Daniel Frantík edited this page Oct 10, 2026 · 6 revisions

WinBox native — GUI-like syntax

Experimental. WinBox native is the experimental transport of 4.0, and addressing it by GUI names is the newest part of it. For production work over the WinBox channel use WinBox CLI, which can also take raw CLI commands.

tik4net lets you address a WinBox native connection in either of two dialects:

  • the API dialect, translated for you — /ip/firewall/filter/print, src-address. This is the standard way, portable across all eleven transports, and the one the O/R mapper uses. How the names are mapped is described on WinBox native connection.
  • WinBox's own names — /IP/Firewall/Firewall Rule, Src. Address: the menu, the window and the field caption, as the WinBox screen shows them. This page is about this one.

This is the WinBox counterpart of CLI raw commands, with one difference you need to know up front: WinBox has no command language. A CLI raw command is a line of text sent unchanged; WinBox speaks numbered binary messages, so there is no text to send unchanged. Its native names are what you can write, and tik4net still resolves them to numbers for you.

Why it looks the way it does: the WinBox tree

WinBox does not know RouterOS menus the way the CLI and the API do. It draws a tree of windows that the router itself describes, in a catalog file it serves for its own version (roteros.jg and friends, fetched once per connection and cached). A trimmed piece of it:

{name:'Firewall Rule', title:'Filter Rules', type:'map', path:[ 20,3 ], c:[
    {name:'Chain',  type:'string', id:'s14'},
    {name:'Action', type:'enm',    id:'u13'},
    ... ]}

Read top-down, that is the whole addressing model:

flowchart LR
    menu["<b>menu</b><br/>IP ▸ Firewall"] --> win["<b>window</b> Firewall Rule<br/>list caption: Filter Rules<br/><i>path:[20,3]</i>"]
    win --> f1["<b>field</b> Chain<br/><i>id:'s14'</i>"]
    win --> f2["<b>field</b> Action<br/><i>id:'u13'</i>"]
    win --> f3["<b>field</b> Src. Address<br/><i>type:'opt'</i>"]
Loading
  • A menu is what you click through in WinBox's left bar. It has no number of its own.
  • A window is one table (or one settings form). It has two labels: its name — Firewall Rule, the caption of the dialog that opens on a row — and its title — Filter Rules, the caption of the list. Its path:[major,minor] is the handler the M2 message is sent to. The numbers move between RouterOS versions; the labels do not.
  • A field is a caption in that window. Its id is a type letter (s string, u number, b flag, …) followed by the numeric key the value travels under — s14 is the string under key 0x14.
  • A request on the wire is therefore handler + command + key/value pairs — [20,3], "get all", 0x… — with no text anywhere.

So the names WinBox gives you are the menu breadcrumb, the window's name and the field caption. They are English labels written for people, not identifiers: Firewall Rule rather than filter, Resources rather than resource, Src. Address with a dot and a space. That is why GUI-like syntax looks like /IP/Firewall/Firewall Rule — it is a path through that tree, and tik4net walks the router's own catalog to turn it into the handler and keys.

Turning it on

using var conn = setup.CreateWinboxNativeConnection(c => c.UseGuiNames = true);

UseGuiNames folds case, turns spaces and _ into - and drops abbreviation dots, then resolves the result against the router's catalog. A name that already resolves as an API name is used as it is, so turning the flag on never changes the meaning of code that uses API names. Rows always come back with API field names (src-address), whichever way you addressed the request.

Turning it on and off per command

UseGuiNames is not a connect-time setting: the resolvers are built per operation and read the flag when the command executes, so it can be scoped to a single call and the rest of the session kept strict:

using var conn = setup.CreateWinboxNativeConnection();            // strict API names by default

conn.UseGuiNames = true;                                           // ← labels accepted from here on
conn.CreateCommandAndParameters("/IP/Firewall/Firewall Rule/set", ".id", id, "Src. Address", "10.0.0.0/24")
    .ExecuteNonQuery();
conn.UseGuiNames = false;                                          // ← back to strict

It is mutable connection state: don't toggle it while the same connection is in use from another thread — set it once before first use instead.

What resolves

Measured on RouterOS 7.24.5. A path that does not resolve throws TikPathNotMappedException before anything is sent.

You write Resolves to
/IP/Firewall/Filter /ip/firewall/filter the API path, any case
/IP/Firewall/Firewall Rule /ip/firewall/filter menu + the window's name
/IP/Firewall/Address List /ip/firewall/address-list
/IP/DNS/DNS Static Entry /ip/dns/static
/System/Resources/Resources /system/resource the window is named Resources too
/IP/Addresses/Address /ip/address
/Interfaces/Interface /interface
/IP/Firewall/Address Lists — the list's caption, not the window's name
/IP/Firewall/Filter Rules — the same
/System/Resources — a menu without its window
/PPP/PPP Secret /ppp/secret the window sits directly under the PPP menu
/PPP/Secrets/PPP Secret — Secrets is the list's caption, not a level of the tree

The rule of thumb: menu breadcrumb, then the window's name — the caption of the dialog that opens when you double-click a row, not the caption of the list or tab you clicked to get there.

When an API path has no window of the same name, teach the connection which window it means — by its labels, before Open:

using var conn = setup.CreateWinboxNativeConnection(c =>
{
    // WinBox tree: PPP ▸ (window) PPP Secret
    c.PathAlias("/ppp/secret", "/ppp/ppp-secret");
});

An alias pins only text, so it keeps working after a RouterOS upgrade renumbers the handler. The numeric escape hatches (PathOverride, FieldOverride) pin the numbers themselves and are described on WinBox native connection.

A practical example: the router as WinBox shows it

The program reads two windows by the names on the WinBox screen and changes one field by its caption — the kind of code you write while looking at WinBox.

// ==========================================================================
// TASK       read System ▸ Resources and the firewall rule list by their WinBox names,
//            then write a field of one rule by its caption
// LEVEL      ADO.NET-like, addressed with WinBox GUI names (UseGuiNames)
// TRANSPORT  WinboxNative — structured WinBox M2, TCP 8291   (experimental)
// ==========================================================================
// ON THE ROUTER: the winbox service, and a user with read,write plus the 'winbox' policy.
//   Step 3 changes the comment of the rule commented "managed-by-tik4net", if one exists.
// ==========================================================================

using System;
using System.Linq;
using tik4net;
using tik4net.WinboxNative;

class Program
{
    const string Host     = "192.168.88.1";
    const string User     = "admin";
    const string Password = "";

    static void Main()
    {
        var setup = new TikConnectionSetup(Host, User, Password);
        using (ITikWinboxNativeConnection conn = setup.CreateWinboxNativeConnection(c => c.UseGuiNames = true))
        {
            // 1. System ▸ Resources — the window is named "Resources" as well.
            var res = conn.CreateCommand("/System/Resources/Resources/print").ExecuteSingleRow();
            Console.WriteLine("cpu-load " + res.GetResponseField("cpu-load") + " %, free memory "
                              + res.GetResponseField("free-memory"));      // ← API names on output

            // 2. IP ▸ Firewall ▸ Filter Rules — rows of the window "Firewall Rule".
            var rules = conn.CreateCommand("/IP/Firewall/Firewall Rule/print").ExecuteList().ToList();
            foreach (var rule in rules)
                Console.WriteLine(rule.GetId() + "  " + rule.GetResponseFieldOrDefault("chain", "?")
                                  + " → " + rule.GetResponseFieldOrDefault("action", "?"));

            // 3. Write by caption. The row is chosen client-side: a native read reads the whole
            //    window anyway, so nothing is lost by filtering here.
            var marked = rules.FirstOrDefault(r => r.GetResponseFieldOrDefault("comment", null) == "managed-by-tik4net");
            if (marked != null)
                conn.CreateCommandAndParameters("/IP/Firewall/Firewall Rule/set",
                        ".id", marked.GetId(),
                        "Comment", "managed-by-tik4net (seen)")
                    .ExecuteNonQuery();
        }
    }
}

Limits

  • Names in, API names out. GUI names are accepted on input only.
  • A caption is folded, not looked up. The flag only folds separators and case, so a caption that does not reduce to its API name that way — Tx for tx-byte — needs a built-in alias or a FieldOverride.
  • Not a raw level. CreateRawCommand and CallCommandSync do not exist on WinBox native (it does not report RawCommand): there is no text to pass through. For a command the native mapping does not cover, open WinBox CLI on the same port and use CLI raw commands.

See also

Clone this wiki locally