I sincerely apologize for the long period of inactivity. Thanks to AI tooling, I finally have some bandwidth again. In the near future I intend to work through all open PRs and critical bugs and publish an updated NuGet package.
To prevent this from happening again, I am looking for collaborators. If you are interested in helping maintain this project, please reach out — open an issue or contact me directly. Special thanks to Deantwo for helping others while I was away.
The next release will target
netstandard2.0only. This should be sufficient for all current use cases — it covers .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5/6/7/8, Xamarin, and Unity.The upcoming release has been tested and debugged against RouterOS 7.21.4 (latest stable).
tik4net is a .NET library for communicating with MikroTik routers via the MikroTik API protocol. It offers a clean, easy-to-use interface that scales from low-level raw API access all the way up to a fully typed O/R mapper, and ships as two NuGet packages:
- tik4net — Basic ADO.NET-like API: R/W access to MikroTik in both synchronous and asynchronous code.
- tik4net.objects — High-level O/R mapper API: strongly typed MikroTik entities with full CRUD support.
- Tools — semi-automatic C# code generators for custom entities (used with tik4net.objects).
- Easy to use with O/R mapper like highlevel API
- Low level access supported by low level API
- Stable interface and backward compatibility
- Broad range of .NET runtimes supported (including .NET core 2 and Xamarin)
- New mikrotik v.6.43 login process supported
- Includes MNDP discovery helper
- Easy to understand and well documented code
Stable
In development (v 3.6)
- Download as sources.
Mikrotik API wiki:
Project wiki:
Examples:
- example project
- support forum
- For VisualBasic trivial example see VB example
using (ITikConnection connection = ConnectionFactory.CreateConnection(TikConnectionType.Api_v2)) // Use TikConnectionType.Api for mikrotikversion prior v6.45
{
connection.Open(HOST, USER, PASS); ITikCommand cmd = connection.CreateCommand("/system/identity/print");
var identity = cmd.ExecuteScalar();
Console.WriteLine("Identity: {0}", identity); var logs = connection.LoadList<Log>();
foreach (Log log in logs)
{
Console.WriteLine("{0}[{1}]: {2}", log.Time, log.Topics, log.Message);
} var firewallFilter = new FirewallFilter()
{
Chain = FirewallFilter.ChainType.Forward,
Action = FirewallFilter.ActionType.Accept,
};
connection.Save(firewallFilter); ITikCommand torchCmd = connection.CreateCommand("/tool/torch",
connection.CreateParameter("interface", "ether1"),
connection.CreateParameter("port", "any"),
connection.CreateParameter("src-address", "0.0.0.0/0"),
connection.CreateParameter("dst-address", "0.0.0.0/0"));
torchCmd.ExecuteAsync(response =>
{
Console.WriteLine("Row: " + response.GetResponseField("tx"));
});
Console.WriteLine("Press ENTER");
Console.ReadLine();
torchCmd.Cancel();- Importing other classes
- Looking for betatesters
- create highlevel classes for all mikrotik entities (you can still generate your own classes)
- create tiklink project - easy use-to wrapper over mikrotik router with fluent API
- convert examples to separate unittests (in progress)
- tiktop — a MikroTik traffic monitor inspired by Linux
iftop(currently in alpha, publication coming soon)
REMARKS: This project is rewritten version of deprecated tik4net at googlecode (last version was 0.9.7.)
- Apache 2.0.