Repository navigation
Home
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).
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
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.
| … | 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.
5.0 — prerelease, 5.0.0-alpha7 on NuGet (Upgrading from 4.x):
- RoMON — reach a router through a neighbouring one, over any CLI or WinBox transport
- One codebase from RouterOS 6.49 to 7.25 — RouterOS versions
- TikField — a property knows whether the router printed the field, and never invents a default
-
Describing menus —
DescribeMenuasks the router which commands, arguments and values a menu takes - Connection string — router, credentials and transport from configuration
-
Passwords out of config files —
password=dpapi:…,env:…orfile:…instead of the password -
Negated matchers and value lists —
src-address=!10.0.0.0/8,dst-port=22,8291as typed values -
Compile-time checks — analyzers TIK001–TIK003 catch
TikFieldcomparisons that can never match, and TIK004 a mapper call with a class that is not an entity - SSH private-key login
- List sync with the fewest moves — ordered menus reordered with minimal moves
- Filtered CLI reads run on the router
- Upgrade with an AI agent — a ready-to-paste migration prompt
4.0 — the current release (Upgrading from 3.x):
- Eleven transports, one contract, including the MAC-layer ones found by MNDP
-
Safe Mode with automatic rollback · Change tracking —
Savesends only what changed - Typed per-transport interfaces and fail-closed capabilities
-
Async and cancellation · Monitors and streaming,
IAsyncEnumerablereads onnet8.0 - MCP server · Upgrade with an AI agent
Every change, version by version: History.
Start
- Getting started — first project
- From the console to tik4net — what you type, what you call
- Building an application — a service, reconnecting, logging
- Library overview
- CRUD at all three levels
- One task, every transport
Connecting
- Connecting to a router — setup, options, connection string
- Transports & capabilities — the matrix
- Threading & concurrency
- API · API-SSL
- REST
-
CLI transports
- Telnet · SSH · WinBox CLI
- MAC-layer transports — no IP needed
- WinBox native · GUI-like syntax
- RoMON — through a neighbouring router
- MNDP discovery
Working with data
- Low-level API — raw sentences
- ADO.NET-like API — commands, parameters
- CLI raw commands · tips & tricks
- Command translation
- Async & cancellation
- Monitors & streaming — ping, torch, listen
O/R mapper
-
High-level API
- Reading data · Create, update, delete
- Change tracking · List merge
- TikField · Value lists & negated matchers · Value types · Helpers
- Entity reference — every covered menu
- Custom entities
Safety
- Safe Mode — rollback protection
- Exception handling
RouterOS
Testing & diagnostics
Extending & tools
Project