Skip to content
Daniel Frantík edited this page Nov 28, 2026 · 102 revisions

tik4net

tik4net is a .NET library for MikroTik RouterOS. One connection contract covers 11 transports — the binary API, REST, Telnet, SSH, the WinBox channel, and MAC-layer variants that need no IP address on the router — so you use whatever the router already has enabled, and switching is one enum value. On top of it you choose your level: raw sentences, an ADO.NET-like command API, or a typed O/R mapper over 170+ RouterOS menus, all on the same connection. Tested on RouterOS 7.25.2, 7.21.5 and 6.49.21 (RouterOS versions).

Install

dotnet add package tik4net            # the library: every transport but SSH, all three API levels
dotnet add package tik4net.ssh        # the SSH transport
dotnet add package tik4net.testing    # TikFakeConnection — unit tests without a router

Quick start

using tik4net;
using tik4net.Objects;
using tik4net.Objects.Ip.Firewall;

var setup = new TikConnectionSetup("192.168.88.1", "admin", "");

using (ITikConnection connection = setup.Create(TikConnectionType.Api))   // or Rest, Ssh, MacTelnet, WinboxCli, …
{
    Console.WriteLine(connection.CreateCommand("/system/identity/print").ExecuteScalar());

    // Adds an entry to the address list "blocked"; remove it with /ip firewall address-list remove [find list=blocked]
    connection.Save(new FirewallAddressList { Address = "10.20.30.40", List = "blocked", Comment = "tik4net quick start" });

    foreach (var entry in connection.LoadList<FirewallAddressList>(connection.CreateParameter("list", "blocked")))
        Console.WriteLine(entry.Address);
}

Step by step, from an empty project: Getting started.

I want to…

… Read
understand how the library fits together Library overview
connect with options, a connection string, another transport Connecting to a router · Transports & capabilities
reach a router with no IP address, or behind another router MAC-layer transports · RoMON · MNDP
read and write typed entities O/R mapper · Entity reference
send a command no entity covers, or the console's own syntax ADO.NET-like API · Low-level API · CLI raw commands
keep a list on the router in sync with mine List merge
run ping, torch or a change listener Monitors and streaming
make risky changes without locking myself out Safe Mode
write async code with cancellation Async and cancellation
handle errors Exception handling
test my code without a router Unit testing without a router
see what goes over the wire Communication debugging · MCP server
upgrade from 4.x or 3.x Upgrading from 4.x to 5.0 · from 3.x to 4.0

All pages are in the sidebar; the same three API levels side by side are on CRUD examples for all APIs.

What's new

5.0 — prerelease, 5.0.0-alpha7 on NuGet (Upgrading from 4.x):

4.0 — the current release (Upgrading from 3.x):

Every change, version by version: History.

Clone this wiki locally