MikroTik is the default router NAS type selected in Splynx when you create a new router. NAS type, in addition to being source of configuration parameters for the Radius, can also be configured to work with Splynx MikroTik API functionality.
Splynx is able to login to the router via MikroTik API to gather traffic statistics, manage shaping, PPP/DHCP/Hotspot authorization entries for clients, firewall rules & address lists and more. You can find detailed info on this subject in following manual: Routers Settings.
By default, Splynx MikroTik API module is enabled only for the default "MikroTik" NAS type and its not possible to change it for existing NAS types.
If you wish to create a custom NAS type with MikroTik API module, go to Config → Networking → NAS types
and create a new NAS type with "MikroTik API" option enabled:
After creating the NAS type - it will be possible to select it for your Router and customize MikroTik API functionality by using info specified below in this manual.
In this example - we have created a NAS type "MikroTik 2" with ID 16.
You can customize Splynx MikroTik API processing for a specific NAS type to have custom names or parameters pushed to the router via MikroTik API by using the instruction below.
Create the following file via CLI & grant permissions on your Splynx server as shown below:
sudo nano /var/www/splynx/config/mikrotik.php
sudo chown splynx:splynx /var/www/splynx/config/mikrotik.php
The file should consist of:
; <?php exit(); ?>
; Do not remove this lines
; Splynx Mikrotik API config file
[16]
You can use keys as variables:
customer_<key>
– key or additional field name from customer's info
service_<key>
– key or additional field name from customer's service
dhcp_leases['address'] = '{ip}';
dhcp_leases['mac-address'] = '{mac}';
dhcp_leases['comment'] = 'MikroTik 2_{customer_id}-{service_id}';
Example of specifying value from service/customer additonal field:
dhcp_leases['server'] = '{service_dhcp_server_name}';
Example file for multiple NAS types with different IDs (16 and 17):
; <?php exit(); ?>
; Do not remove this lines
; Splynx Mikrotik API config file
[16]
dhcp_leases['address'] = '{ip}';
dhcp_leases['mac-address'] = '{mac}';
dhcp_leases['comment'] = 'MikroTik 2_{customer_id}-{service_id}';
dhcp_leases['server'] = '{service_dhcp_server_name}';
[17]
dhcp_leases['address'] = '{ip}';
dhcp_leases['mac-address'] = '{mac}';
dhcp_leases['comment'] = 'MikroTik 3_{customer_id}-{service_id}';
How it will look when applied to the router:
dhcp_leases['address'] = '{ip}';
dhcp_leases['mac-address'] = '{mac}';
dhcp_leases['comment'] = 'SpLUser_{customer_id}-{service_id}';
filter_rule_1["chain"] = "forward"
filter_rule_1["action"] = "accept"
filter_rule_1["src-address"] = "{ip}"
filter_rule_1["src-mac-address"] = "{mac}"
filter_rule_1["comment"] = "SpLUser_{customer_id}-{service_id}-1"
filter_rule_2["chain"] = "forward"
filter_rule_2["action"] = "accept"
filter_rule_2["dst-address"] = "{ip}"
filter_rule_2["comment"] = "SpLUser_{customer_id}-{service_id}-2"
hs_users["name"] = "{login}"
hs_users["password"] = "{password}"
hs_users["profile"] = "default"
hs_users["address"] = "{ip}"
hs_users["mac-address"] = "{mac}"
hs_users["comment"] = "SpLUser_{customer_id}-{service_id}"
ppp_secrets["name"] = "{login}"
ppp_secrets["password"] = "{password}"
ppp_secrets["profile"] = "default"
ppp_secrets["service"] = "any"
ppp_secrets["remote-address"] = "{ip}"
ppp_secrets["routes"] = "{routes}"
ppp_secrets["comment"] = "SpLUser_{customer_id}-{service_id}"
simple_user["name"] = "SpLSQ_{customer_id}-{service_id}"
simple_user["max-limit"] = "{out}/{in}"
simple_user["limit-at"] = "{out_at}/{in_at}"
simple_user["priority"] = "{priority}/{priority}"
simple_user["target-addresses"] = "{ip}"
simple_user["burst-limit"] = "{b_out}/{b_in}"
simple_user["burst-threshold"] = "{bt_out}/{bt_in}"
simple_user["burst-time"] = "{b_time}/{b_time}"
simple_user["queue"] = "{qs}"
simple_user["comment"] = "{login}"
simple_tree_user["name"] = "SpLSTQ_{customer_id}-{service_id}"
simple_tree_user["max-limit"] = "{out}/{in}"
simple_tree_user["limit-at"] = "{out_at}/{in_at}"
simple_tree_user["priority"] = "{priority}/{priority}"
simple_tree_user["target-addresses"] = "{ip}"
simple_tree_user["burst-limit"] = "{b_out}/{b_in}"
simple_tree_user["burst-threshold"] = "{bt_out}/{bt_in}"
simple_tree_user["burst-time"] = "{b_time}/{b_time}"
simple_tree_user["queue"] = "{qs}"
simple_tree_user["comment"] = "{login}"