Run RouterOS in Azure

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.

1. Step

Download the CHR VHDX image from MikroTik.

download chr vhdx image

2. Step

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

3. Step

In Azure you will need to create a storage account: (use Azure CLI in your terminal) If you prefer GUI, you can do this few steps on Azure portal, the parameters are the same.

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

4. Step

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

5. Step

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

6. Step

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

7. Step

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
No alt text provided for this image

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.

No alt text provided for this image

Create an inbound rule for Winbox 8291 port.

No alt text provided for this image

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!



邮箱地址不会被公开。 必填项已用*标注