I'm working with mikrotik for more then two years now and I must say that its very convenient piece both software and hardware. My needs for the router capabilities getting bigger and bigger and I must say that mikrotik is doing its job!

Recently my private IPSec network grew a bit and I needed to re-organise. Realized that I miss another router but maybe not the regular mikrotik hardware. Fortunately router os software is available to download in many different versions.

Decided to try Cloud Hosted Router (CHR).

Its a RouterOS version intended for running as a virtual machine. It supports the x86 64-bit architecture and can be used on most of the popular hypervisors such as

  • VMWare
  • Hyper-V
  • VirtualBox
  • KVM and others.

CHR has full RouterOS features enabled by default but has a different licensing model than other RouterOS versions and for free you get everything but limited to 1Mbit!

As I don't have access to any of the hypervisors mentioned above, so decided to try running it on my private Xen Hypervisor (4.4) running on linux (Debian 8.11). I'll try to show how to do it in the future.

Preparations

So let's assume we already have this on our server:

  1. 64bit CPU with virtualization support - check in /pro/proc/cpuinfo or lscpu.
  • check if your CPU is 64 bit by checking flag lm in /proc/cpuinfo
  • check if your have hardware virtualization support - flags vmx(intel) and svm(amd)

2. XEN Hypervisor up and running

root@server:~# xl info |grep xen
xen_major              : 4
xen_minor              : 4
xen_extra              : .1
xen_version            : 4.4.1

3. LVM prepared to work with xen

4. 128 MB or more RAM for the CHR instance (needs minimum 128MB of RAM to complete the self-installation process)

Installation

  1. Create logical volume  (RouterOS is capable to see max 16GB)
root@server:~# lvcreate -L16G -n router_r1_root vg0
  Logical volume "router_r1_root" created

2. Download CHR RAW disk image from https://mikrotik.com/downloads/ and put it into fresh created /dev/vg0/router_r1_root

root@server:~# wget -q https://download.mikrotik.com/routeros/6.42.5/chr-6.42.5.img.zip
root@server:~# unzip chr-6.42.5.img.zip
Archive:  chr-6.42.5.img.zip
  inflating: chr-6.42.5.img          

root@server:~# fdisk -l chr-6.42.5.img
Disk chr-6.42.5.img: 128 MiB, 134217728 bytes, 262144 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device          Boot Start    End Sectors Size Id Type
chr-6.42.5.img1 *        1  65536   65536  32M 83 Linux
chr-6.42.5.img2      65537 262143  196607  96M 83 Linux

root@server:~# dd if=chr-6.42.5.img of=/dev/vg0/router_r1_root bs=4M
32+0 records in
32+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 2,52498 s, 53,2 MB/s

3. Prepare xen config.

Here you can either use xen-tools to create a fresh vm or just copy out the config and adjust specific settings:

/etc/xen/auto/router_r1.cfg

# Configuration file for the Xen instance router_r1
#
#  Builder + memory size
#

builder='hvm'
type='hvm'
vcpus       = '2'
memory      = '512'
maxmem      = '512'

#
#  Hostname
#

name        = 'r1.f17.eu'

#
#  Disk device(s).
#

root        = '/dev/xvda rw'
disk        = [
                  'phy:/dev/vg0/router_r1_root,xvda,rw',
             ]

#
#  Networking
#

vif         = [ 'ip=10.0.0.2, mac=00:14:3F:6D:29:15, bridge=xenbr0',
                'mac=00:16:3E:D7:C7:11, ip=111.222.333.444/32' 
              ]
#
#  VNC config
#
# Use VNC for display

vnc = 1 
vnclisten = "10.0.0.1"
vncdisplay = 0  

vfb = [ 'type=vnc' ]
stdvga = 1
vncconsole=1
vncpasswd=''
sdl = 0 

# Use VESA-compliant display with more VRAM
acpi = 1
apic = 1
pae = 1
viridian = 0
device_model = '/bin/true'

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

4. Start the VM and connect to the VNC

root@server:~#xl create /etc/xen/auto/router_r1.cfg 

root@server:~# netstat -lntp |grep 5900
tcp     0   0 10.0.0.1:5900       0.0.0.0:*     LISTEN  18667/qemu-system-i

root@server:~# xl list 
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  6064     4     r-----  38825456.4
router_r1                                    1   512     2     -b----    1646.2
root@localhost:~# vncviewer 10.0.0.1
NC Viewer Free Edition 4.1.1 for X - built Feb 25 2015 22:57:51
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Fri Jul 13 15:28:40 2018
 CConn:       connected to host 10.0.0.1 port 5900
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
 TXImage:     Using default colormap and visual, TrueColor, depth 24.
 CConn:       Using pixel format depth 6 (8bpp) rgb222
 CConn:       Using ZRLE encoding

you should be able to see that the self-installation process started and a fresh installation of our RouterOS CHR edition is in progress! It needs another reboot and your done!