Network automation lab 26 of 27
MikroTik RouterOS REST API: HTTPS, CRUD and desired state
Automate two RouterOS routers through their REST API: move it from plain HTTP to verified HTTPS, learn how GET, PUT, PATCH, DELETE and POST map to RouterOS commands, build a routed link and OSPF from a YAML file with a script you can run twice, and give an API account only the rights it needs.
Run this lab
It needs Lite: its 3 nodes are set to 3 vCPU and 1,536 MB in total. That fits the free demo too.
In your workspace: Shared, then Network Automation - CCNA and CCNP Automation guided labs, then 26 - MikroTik RouterOS REST API - HTTPS CRUD and desired state
- Level
- Intermediate
- Time
- About 70 minutes
- Nodes need
- 3 vCPU, 1,536 MB
- Smallest plan
- Lite
The scenario
Kestrel's two smallest depots run MikroTik CHR routers. Nobody wants to log in to each one by hand, and RouterOS 7 has a REST API, so that's your way in. But it starts life on plain HTTP with a password on every request, so the first job is to fix that. Then you'll build the link between the depots from a YAML file, with a script that's safe to run twice.
| Router | Platform | Mgmt address | Loopback (to build) | Link (to build) |
|---|---|---|---|---|
| mt1 | RouterOS 7.14 (CHR) | 10.10.20.61 | 10.255.1.1/32 | ether2 10.1.62.1/30 |
| mt2 | RouterOS 7.14 (CHR) | 10.10.20.62 | 10.255.1.2/32 | ether2 10.1.62.2/30 |
What you’ll practise
- Explain why basic authentication needs HTTPS, and enable www-ssl with certificates made on the router
- Verify a device's certificate from a client, with cURL and Python, instead of switching verification off
- Map GET, PUT, PATCH, DELETE and POST to RouterOS print, add, set, remove and commands
- Filter replies with .proplist and .query, and read RouterOS error replies
- Write an idempotent script that builds addresses and OSPF from a YAML file
- Limit an API account with user groups and the rest-api policy
The tasks
- See the problem
- Move to HTTPS, with a certificate you can check
- Trust it properly
- The REST verbs, the RouterOS way
- Build from a file, safely
- Ask the routers how it went
- Errors and least privilege
- Configuration out over REST
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- devbox
eth0to Mgmt (network) - mt1
ether1to Mgmt (network) - mt2
ether1to Mgmt (network) - mt1
ether2to mt2ether2
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| devbox | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| mt1 | MikroTik RouterOS | mikrotik-7.14.2 | 1 vCPU, 256 MB |
| mt2 | MikroTik RouterOS | mikrotik-7.14.2 | 1 vCPU, 256 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Network Automation - CCNA and CCNP Automation guided labs.Open
26 - MikroTik RouterOS REST API - HTTPS CRUD and desired stateand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Network automation labs
Related labs in other courses
CloudLabBox is independent of Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.