Installing CT on Mikrotik

This has been tested on the following models

  • RB2011UiAS-IN
    - Fast Ethernet ( Switch 2 - ETH6-ETH10 right-hand side ) doesn't work for now. Should get amended in the next release 
  • RB951G-2HnD
    - No known issues so far

Saving your MikroTik RouterBoard software key

To ensure you have the option to return to RouterOS after flashing our firmware, you will need to save your RouterOS key. There are three options to do this:

Option 1 - Retrieve from Winbox

If you have access to the MikroTik's Winbox software, you can export the license file from System→Licence→Export Key. See  http://wiki.mikrotik.com/wiki/Manual:License

Option 2 - Export from RouterOS Console

/system license output

Then list the files on your device to see which file the .key file was saved:

/file print

On a fresh install, the key file should be #1 (or #0 on a RB433UAH).

Copy contents, alternative 1: to open the editor with file #1, type:

/file edit 1 value-name=contents

Then copy-paste the text in a file on your computer. (this alternative only supports text files)

Option 3 - Download from web interface

http://192.168.88.1/webfig/#Files

This key contains line spacing and a SoftwareID line that the other options will not have. If using this method, please remove all of the empty lines and SoftwareID line before importing.


Flashing Instruction for routerboard with a serial console port (RB2011UiAS-IN).

Things might just go wrong. That's plain and simple. It is best to get a serial console before proceeding.

Routerboards have a bootloader that can boot and run a .elf file of OpenWrt with initramfs, aka: a single file with the whole OpenWrt package: kernel plus filesystem. A routerboard has at least three flash partitions: bootloader, kernel and root, so this bootloader is preserved even after OpenWrt is installed onto NAND flash later and OpenWrt on flash is booted from the in-flash routerboard bootloader.

1) Connect your serial console, open Putty or your favourite terminal emulator, set the speed to 115200 and select the right usb interface then open it. (More details on the Mikrotik website  http://wiki.mikrotik.com/wiki/Manual:Netinstall#OPTIONAL:_Configuring_RouterBOARD_with_COM_port)

2) Download the firmware from CT and save it somewhere you know about.

3) You will need to create a DHCP server on your machine with some options in order to send the firmware. On Ubuntu this is quite easy. You will need to create a script like this.

#/bin/bash
ifconfig eth0 192.168.1.10 up
dnsmasq -i eth0 --dhcp-range=192.168.1.100,192.168.1.200 \
--dhcp-boot=openwrt-ar71xx-mikrotik-vmlinux-initramfs.elf \
--enable-tftp --tftp-root=/home/user/mikrotik/trunk/bin/ar71xx/ -d -u test -p0 -K --log-dhcp --bootp-dynamic

In the above replace

  • eth0 with the correct name of your wired interface.
  • /home/user/mikrotik/trunk/bin/ar71xx/ with the path where you saved the image.
  • firmware.bin with the name of the firmware downloaded.
  • test with the username of your machine.

4) Make that script executable with   sudo chmod +x script.sh

5) Run the script with ./script.sh

6) Now plug the cable into the WAN port (usually Eth1) of your Mikrotik and also disable your WiFi card. Sometimes the subnet used on the wired will conflict with the one you have on your WiFi. You may also need to disable your wired interface as this can conflict with the settings outlined  in the script.

7) Power the router and you should see the prompt displaying board info. Once prompted hit Enter before the 3 second timeout

8) You should get the option menu. Type "p" which is for boot protocol and select "2" - dhcp protocol

9) Type "o" - boot device now and enter "1" boot Ethernet once, then NAND

10) Type "x" and it will exit and reboot.

11) If everything is ok, the firmware will start to be transferred from your PC/Laptop to the AP and you should be seeing something like

dnsmasq-tftp: sent /media/andrew/SSD/build-dir/CC-160317-00/bin/ar71xx/firmware.bin to 192.168.1.xxx

The process can take up to 5 Minutes during which you will see all the LEDs on the box flashing.

12) Close the tftp script before continuing. Unplug the cable from your laptop/PC and connect it to a network with a working internet connection. Go to you CT dashboard and discover the box.


Flashing Instruction for routerboard without a serial console port (RB951G-2HnD).

1) Connect a PC to a LAN port. Log into your RouterOS interface 192.168.88.1 and set router to boot from ethernet once with DHCP:

System → Routerboard → Settings → Boot device: Try ethernet once then NAND System → Routerboard → Settings → Boot protocol: DHCP System → Routerboard → Settings → Force Backup Booter: Checked (if supported by your routerboard - !IMPORTANT) Save

Reboot routerboard. This will boot from TFTP once. The boot protocol setting will stay persistent across reboots, but the next reboot will be again from NAND (the bootloader resets this parameter after booting from TFTP once)

2) Download the firmware from CT and save it somewhere you know about.

3) You will need to create a DHCP server on your machine with some options in order to send the firmware. On Ubuntu this is quite easy. You can create a script like this.

#/bin/bash
ifconfig eth0 192.168.1.10 up
dnsmasq -i enp7s0 --dhcp-range=192.168.1.100,192.168.1.200 \
--dhcp-boot=firmware_name.bin \
--enable-tftp --tftp-root=/home/user/directory/ -d -u user_name -p0 -K --log-dhcp --bootp-dynamic

In the above replace

  • eth0 with the correct name of your wired interface.
  • /home/user/directory/ with the path where you saved the image.
  • firmware_name.bin with the name of the firmware downloaded.
  • user_name with the username of your machine.

4) Make that script executable with  chmod +x script.sh

5) Run the script with   sudo ./script.sh

6) Now plug the cable into the WAN port (usually port 1) of your Mikrotik and also disable your PC WiFi card. Sometimes the subnet used on the wired interface will conflict with the one you have on your WiFI.

7) Hold reset button and plug the power cable (on some models this is just a hole with a hidden push button switch) Observe activity LED.It first goes on continuously. Then it flashes. Then it goes on continuously. Then it goes off continuously. This will take 15..20 seconds. Then a beep sounds (5 seconds later).Release reset button.

8) If everything is ok, the firmware will start to be transferred from your PC/Laptop to the AP and you should be seeing something like the following:

dnsmasq-tftp: sent /home/user/directory/firmware_name.elf to 192.168.1.xxx

*If you are seeing in your script output something like - dnsmasq-dhcp: DHCP packet received on enp7s0 which has no address - please start stop the script "Ctrl+C" and start from step 5 again

The process can take up to 5 Minutes during which you will see all the LEDs on the box flashing.

9) Close the tftp script before continuing. Unplug the cable from your laptop/PC and connect it to a network with a working internet connection. Go to you CT dashboard and discover the box.


Troubleshooting:

  • Firstly recheck this tutorial, that you have followed all the steps.
  • Make sure when you run the DHCP server on your machine, you have also disabled the WiFi connection.
  • Check the serial output for any obvious errors.