Yes, it’s possible to have a (virtual) MikroTik router in the cloud.
MikroTik provide a version of RouterOS which 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. This version name is MikroTik CHR, (Cloud Hosted Router).
By default in the MS Azure marketplace there are no MikroTik appliance templates, but you can create custom OS images to deploy a virtual machine.
Download the CHR VHDX image from MikroTik. https://mikrotik.com/download
Azure supports only VHD files to create OS images. Convert VHDX image to a VHD! For this, use Powershell and use fixed type virtual disk!
Convert-VHD -Path C:\temp\chr-6.46.7.vhdx -DestinationPath C:\temp\chr-6.46.7.vhd -VHDType Fixed
az storage account create --name chrteststorageaccount --resource-group DemoRSC
If it’s successfull, you have to create a container within the storage account. There will be uploaded the VHD image.
az storage container create --name imagecontainer --account-name chrteststorageaccount
Upload the CHR image. (use your own account key instead of xxxx) The new VHD must be a page blob.
az storage blob upload --account-key xxxx --account-name chrteststorageaccount --container-name imagecontainer --file C:/temp/chr-6.46.7.vhd --name chr-6.46.7.vhd --type page
Create an OS image from the uploaded image: (CHR image only supports Hyper-V generation 1, ‘V1’ virtual machines)
az image create --name chr646image --resource-group DemoRSC --location northeurope --os-type linux --hyper-v-generation V1 --source https://chrteststorageaccount.blob.core.windows.net/imagecontainer/chr-6.46.7.vhd
Finally deploy a VM from the image: (select a cheap vm size, Standard_B1ls is more than enough and it’s only 4EUR / month)
az vm create --name CHRVM --resource-group DemoRSC --location northeurope --size Standard_B1ls --image chr646image --admin-username username --admin-password Apple123456789@ --nsg-rule SSH
Get the VM’s public IP address and connect via SSH:
$ip = az vm show -d --resource-group DemoRSC --name CHRVM --query publicIps -o tsv ssh username@$ip
Winbox is also working, but for this, first you have to create a rule in the automatically-created network security group, which controls the VM’s network traffic. The network security group belongs to the VM’s network interface resource not the VM, so this configuration is a littlebit easier on GUI.
Create an inbound rule for Winbox 8291 port.
Now you can connect to the CHR’s public IP with Winbox and SSH too.
Enjoy your MikroTik router in Azure! 🙂
(Configure interfaces, IP addresses and routes are a littlebit complex but not impossible. You have to know how Azure networking works. See my next article!)
WARNING: Winbox and SSH with username/passsword via a public IP address is very unsecure but it’s just a demo. Secure your connections in productional environment!