Skip to content
@jennifer/routeros

routeros documentation

routeros is a thick, friendly layer over the MikroTik RouterOS API for the Jennifer language. Each guide below covers one topic file of the module with background, the full function surface, worked examples, and the pitfalls the abstraction protects you from.

Conventions used in every guide

All snippets assume an established connection:

jennifer
import "@jennifer/routeros/" as mt;

def c as mt.Client init mt.connect("192.168.88.1", "admin", "secret");
# ... snippets go here ...
mt.disconnect($c);

Errors: every validation failure raised by routeros is an Error{kind: "routeros"} with a human-readable message; errors coming from the router or the wire are Error{kind: "mikrotik"}. Catch either with try { ... } catch (e) { io.printf("%s\n", $e.message); }.

Verbose mode: $c = mt.setVerbose($c, true); prints every command the client sends to stdout (mt> /ip/address/add address=... interface=...), with credentials redacted - see core.md. It returns a copy, so keep the returned client. MT_VERBOSE=1 in the environment turns it on at connect time without touching the script.

Ids: RouterOS gives every list item an internal id like "*3". The add* functions return it, the typed structs carry it in .id, and the generic verbs accept it. Most routeros helpers let you use a name or a comment instead, so you rarely touch ids directly.

The condensed, everything-on-one-page reference is cheatsheet.md. For the RouterOS side itself - every menu, property, and behavior these topics wrap - see MikroTik's official RouterOS documentation.

Guides

GuideCovers
cheatsheet.mdthe whole API surface on one page
core.mdconnecting, the generic add/set/remove verbs, shared validation
interfaces.mdlisting, enabling, renaming physical and virtual interfaces
interfacelist.mdinterface lists: WAN/LAN groups for firewall matching
lte.mdLTE / cellular uplink: signal, APN, backup WAN
ethernet.mdport settings: speed, duplex, MTU, PoE, link state
bonding.mdlink aggregation: LACP trunks, failover bundles
bridges.mdbridges and bridge ports (virtual switches)
switch.mdswitch chip: hardware offload inventory and verification
vlans.md802.1Q tagged interfaces
firewall.mdfilter rules: the builder, comment handles, shortcuts
nat.mdmasquerade and port forwarding
upnp.mdUPnP: LAN devices open their own port forwards
trafficflow.mdNetFlow / IPFIX export to a collector
raw.mdfirewall raw: pre-conntrack drop / notrack
addresslist.mdfirewall address lists: one rule, living list
mangle.mdpacket marking: queue marks, policy routing, MSS clamp
contrack.mdconnection tracking: the live connection table
ip.mdIP addresses on interfaces
ipv6.mdIPv6: the stack switch, addresses, router advertisements
arp.mdthe ARP table: who is on the LAN, pinned bindings
neighbor.mdneighbor discovery: what is on this segment (LLDP/CDP/MNDP)
dhcp.mdDHCP server, leases, and the WAN-side DHCP client
ppp.mdPPPoE dial-in WAN (DSL/fiber)
hotspot.mdthe captive guest portal: vouchers, bypass, walled garden
vpn.mdremote-access VPN: L2TP, SSTP, OpenVPN, IKEv2, PPP users
dns.mdresolver settings and static DNS entries
routing.mdstatic routes and the default route
queues.mdbandwidth limiting with simple queues
wireless.mdWiFi: SSIDs, passwords, guest networks, clients (classic menu)
wifi.mdmodern WiFi (wifiwave2/ax, RouterOS v7)
wireguard.mdWireGuard VPN tunnels (RouterOS v7)
eoip.mdEoIP: one LAN across two sites
gre.mdGRE: routed site-to-site links, any vendor
ipsec.mdIPsec: standards-based site-to-site, multi-vendor
vrrp.mdVRRP: two routers, one gateway, automatic failover
tools.mdping, bandwidth test, fetch, e-mail alerting
sms.mdtext messages over the cellular modem
netwatch.mdcontinuous host monitoring with on-change scripts
scheduler.mdscripts on a timer
script.mdthe stored-script repository (run by name)
users.mdrouter accounts, groups, active sessions
services.mdmanagement services: hardening the ways in
certificates.mdTLS: self-signed, Let's Encrypt, the acme flow
clock.mdclock and NTP: a router that knows what time it is
files.mdfiles and configuration backups
disk.mdstorage devices: list, format, eject
cloud.mdMikroTik Cloud DDNS: a stable name for a dynamic WAN
snmp.mdSNMP: plug the router into monitoring
radius.mdRADIUS: central authentication for logins/VPN/hotspot
health.mdsystem health: temperature, voltage, fans
container.mdrun OCI containers on the router (v7)
capsman.mdCAPsMAN: central management of many access points
log.mdreading the router log, routing what gets logged
system.mdpackages, updates, firmware, reboot

One runnable example per topic lives in ../examples/ (MT_HOST=... MT_USER=... MT_PASSWORD=... jennifer run examples/<topic>.j).

Disclaimer

MikroTik and RouterOS are trademarks of SIA Mikrotīkls. routeros is an independent, community-written client library, not affiliated with, endorsed, or supported by SIA Mikrotīkls - and it configures live network equipment. Use at your own risk; no warranty of any kind.

Licensed under the GNU LGPL v3.0 only - see ../LICENSE.

Running the tests

sh
jennifer test src/routeros_test.j

The white-box overlay exercises everything network-free: validators, row folding, builders, and normalization. Functions that need a live router are thin compositions of those tested helpers.