$npx -y skills add tikoci/routeros-skills --skill routeros-netinstallMikroTik netinstall-cli for automated RouterOS device flashing. Use when: automating netinstall, writing scripts that invoke netinstall-cli, building netinstall tooling, understanding etherboot/BOOTP/TFTP protocols, working with RouterOS package files (.npk), using modescript or
| 1 | # RouterOS Netinstall |
| 2 | |
| 3 | This skill focuses on **official Netinstall / `netinstall-cli` behavior**. `tikoci/netinstall` is a useful wrapper and source of grounded examples, but it is only one way to drive the tool. |
| 4 | |
| 5 | ## What `netinstall-cli` Does |
| 6 | |
| 7 | Netinstall reinstalls RouterOS onto a device that has booted into **etherboot** mode. The Linux tool, `netinstall-cli`, listens for BOOTP requests and then sends the RouterOS boot image and selected `.npk` packages. |
| 8 | |
| 9 | Grounded behavior from MikroTik docs: |
| 10 | |
| 11 | - Netinstall **re-formats the system drive** |
| 12 | - It **does not erase the RouterOS license key** |
| 13 | - It **does not reset RouterBOOT settings** |
| 14 | - It works over a direct **Layer 2** path using **BOOTP/DHCP ports** and **TFTP** |
| 15 | - It requires **root / sudo** |
| 16 | |
| 17 | `netinstall-cli` is the Linux command-line variant. The Windows GUI exposes nearly the same core options. |
| 18 | |
| 19 | ## Command Syntax |
| 20 | |
| 21 | ```text |
| 22 | netinstall-cli [-r] [-e] [-b] [-m [-o]] [-f] [-v] [-c] |
| 23 | [-k <keyfile>] [-s <userscript>] [-sm <modescript>] |
| 24 | [--mac <mac>] {-i <interface> | -a <client-ip>} [PACKAGES...] |
| 25 | ``` |
| 26 | |
| 27 | ## Flags |
| 28 | |
| 29 | | Flag | Meaning | |
| 30 | |---|---| |
| 31 | | `-r` | Reinstall and apply the default-configuration stage | |
| 32 | | `-e` | Reinstall with empty configuration | |
| 33 | | `-b` | Discard the currently installed branding package | |
| 34 | | `-m` | Enable repeated installs in one run | |
| 35 | | `-o` | With `-m`, only reinstall a given MAC once per run; by itself it behaves like a normal single install | |
| 36 | | `-f` | Ignore storage-size checks | |
| 37 | | `-v` | Verbose output | |
| 38 | | `-c` | Allow multiple netinstall instances on the same host | |
| 39 | | `-k <keyfile>` | Install a license key (`.KEY`) | |
| 40 | | `-s <userscript>` | Install a persistent **configure script** that replaces the RouterOS-supplied default configuration script | |
| 41 | | `-sm <modescript>` | Install a one-time **mode script** for the first boot after install | |
| 42 | | `--mac <mac>` | Only respond to this MAC address | |
| 43 | | `-i <interface>` | Bind to a specific interface | |
| 44 | | `-a <client-ip>` | Assign a specific client IP; if `-i` is used, server IP is auto-detected | |
| 45 | |
| 46 | ## Hard Rules |
| 47 | |
| 48 | 1. **The system package must be listed first.** Put `routeros-...npk` first in the package list. |
| 49 | 2. **Root privileges are required.** Netinstall uses privileged BOOTP/TFTP ports. |
| 50 | 3. **Multi-arch package sets are allowed.** Netinstall detects the device architecture and only uses matching packages. |
| 51 | 4. **No `-r` and no `-e` means "keep old configuration".** Netinstall downloads the current configuration database, reformats the device, and uploads that configuration back. This does **not** preserve user files or databases such as Dude or User Manager. |
| 52 | |
| 53 | ## Install Workflow and Script Order |
| 54 | |
| 55 | The official workflow is: |
| 56 | |
| 57 | 1. Put the device into **etherboot** |
| 58 | 2. Run Netinstall with the desired packages and optional scripts |
| 59 | 3. On the next boot, RouterOS runs the initial-configuration steps |
| 60 | |
| 61 | For Linux `netinstall-cli`, the important first-boot order is: |
| 62 | |
| 63 | 1. **Mode script (`-sm`) runs first** |
| 64 | 2. **Custom/default configuration runs after that** |
| 65 | 3. If the mode script changes **device-mode**, the device **reboots immediately** after the mode script completes |
| 66 | |
| 67 | That ordering matters: use `-sm` for first-boot state that must happen **before** default or custom configuration, especially **`/system/device-mode`** and **protected-routerboot**. |
| 68 | |
| 69 | ## Configure Script vs Mode Script |
| 70 | |
| 71 | The docs use several names for the persistent `-s` script: **configure script**, **initial configuration**, and the custom default configuration script visible at: |
| 72 | |
| 73 | ```routeros |
| 74 | /system/default-configuration/custom-script/print |
| 75 | ``` |
| 76 | |
| 77 | These two script types are different: |
| 78 | |
| 79 | | Feature | Configure script (`-s`) | Mode script (`-sm`) | |
| 80 | |---|---|---| |
| 81 | | Purpose | Replace RouterOS-supplied default config script | One-time first-boot actions before config scripts | |
| 82 | | When it runs | As the device's default-configuration stage | On first boot after install, before custom/default config | |
| 83 | | Persistence | Stored on device | Auto-removed after execution | |
| 84 | | Survives upgrades | Yes | No | |
| 85 | | Later `/system reset-configuration` | Runs again after reset | Does not persist for later resets | |
| 86 | | Version requirement | Available in RouterOS 7.x docs | Requires **RouterOS 7.22+** and **netinstall-cli 7.22+** | |
| 87 | | Timeout | 120 seconds | 120 seconds | |
| 88 | | File format | Regular RouterOS import file (`.rsc`) | Regular RouterOS import file (`.rsc`) | |
| 89 | |
| 90 | Additional grounded details: |
| 91 | |
| 92 | - Configure scripts can read `$defconfPassword` and `$defconfWifiPassword` starting with **RouterOS 7.10beta8** |
| 93 | - MikroTik docs explicitly suggest introducing a |