Unique complex mikrotik API communication solution.
The tik4net project provides easy to use API to connect and manage mikrotik routers via mikrotik API protocol. It has 3 parts:
- Basic ADO.NET like API - to perform R/W access to mikrotik in both sync and async code (tik4net.dll).
- O/R mapper like highlevel API with imported mikrotik strong-typed entities. (tik4net.objects.dll)
- Tools - semi-automatic generators of custom entity C# code (for usage with tik4net.objects.dll)
- 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)
- create and contribute to tiktop (see linux iftop) project
REMARKS: This project is rewritten version of deprecated tik4net at googlecode (last version was 0.9.7.)
- Apache 2.0.