CHR: Installing on KVM
CHR: Installing on KVM
Section titled “CHR: Installing on KVM”This guide covers deploying RouterOS Cloud Hosted Router (CHR) on KVM/QEMU using the RAW disk image. KVM is the recommended hypervisor for Linux hosts and provides the best performance via Virtio paravirtualized drivers.
Prerequisites
Section titled “Prerequisites”- Linux host with KVM support (
grep -E 'vmx|svm' /proc/cpuinfomust return output) qemu-kvm,libvirt, andvirt-managerorvirshinstalled- At least 256MB RAM and 128MB disk available for the CHR VM
- Root or
libvirtgroup membership
Download the CHR Image
Section titled “Download the CHR Image”- Visit the MikroTik download page
- Select the Cloud Hosted Router section
- Download the RAW disk image (
.imgfile) for your desired RouterOS version
# Example: download and decompress CHR imagewget https://download.mikrotik.com/routeros/7.x/chr-7.x.img.zipunzip chr-7.x.img.zipMove the image to a libvirt storage pool:
sudo mv chr-7.x.img /var/lib/libvirt/images/chr.imgCreate the Virtual Machine
Section titled “Create the Virtual Machine”Using virt-install (CLI)
Section titled “Using virt-install (CLI)”sudo virt-install \ --name chr \ --memory 1024 \ --vcpus 2 \ --disk /var/lib/libvirt/images/chr.img,format=raw,bus=virtio \ --network network=default,model=virtio \ --os-variant linux2022 \ --import \ --noautoconsoleKey parameters:
| Parameter | Value | Reason |
|---|---|---|
--disk bus=virtio | virtio | Best performance; CHR supports Virtio disk |
--network model=virtio | virtio | Best performance; enables Fast Path in v7 |
--import | — | Uses existing disk image, no ISO installer |
--os-variant linux2022 | linux | Closest match for CHR guest type |
Using virt-manager (GUI)
Section titled “Using virt-manager (GUI)”- Open Virtual Machine Manager
- Click File → New Virtual Machine
- Select Import existing disk image
- Browse to the
.imgfile - Set OS type to Generic Linux
- Allocate RAM (1024MB recommended) and CPU count
- Before finishing, check Customize configuration before install
- In NIC settings, change model to virtio
- In Disk settings, verify bus is VirtIO
- Click Begin Installation
Network Interface Configuration
Section titled “Network Interface Configuration”For multiple network interfaces, add additional NICs using virsh after VM creation:
# Add a second virtio NIC to the default networksudo virsh attach-interface chr --type network --source default \ --model virtio --config --liveInside RouterOS, interfaces appear as etherN in order of MAC address:
/interface printInitial Login and Configuration
Section titled “Initial Login and Configuration”Connect to the VM console:
sudo virsh console chrLog in with the default credentials:
Username: adminPassword: (empty — press Enter)Perform initial configuration:
# Set admin password/user set admin password=StrongPassword123!
# Assign IP address to first interface/ip address add address=192.168.88.1/24 interface=ether1
# Add default route/ip route add dst-address=0.0.0.0/0 gateway=192.168.88.254
# Set DNS servers/ip dns set servers=1.1.1.1,8.8.8.8
# Enable SSH/ip service enable sshKVM Guest Agent
Section titled “KVM Guest Agent”CHR supports the QEMU guest agent for host-guest integration on KVM:
# Add virtio-serial device and guest agent channel when creating the VMsudo virt-install \ --name chr \ --memory 1024 \ --vcpus 2 \ --disk /var/lib/libvirt/images/chr.img,format=raw,bus=virtio \ --network network=default,model=virtio \ --channel unix,target_type=virtio,name=org.qemu.guest_agent.0 \ --os-variant linux2022 \ --import \ --noautoconsoleWith the guest agent active, the host can:
- Execute scripts inside the guest:
virsh qemu-agent-command chr '{"execute":"guest-exec",...}' - Transfer files:
guest-file-open,guest-file-write,guest-file-close - Retrieve network interface info:
guest-network-get-interfaces
Performance Optimization
Section titled “Performance Optimization”For production deployments:
# Use multiple vCPUs for higher interface counts# RAM formula: 256 + [8 × CPU_COUNT × (INTERFACE_COUNT - 1)] MB# Example: 2 CPUs, 4 interfaces → 256 + [8 × 2 × 3] = 304MB minimumVLAN Configuration on Linux Bridge
Section titled “VLAN Configuration on Linux Bridge”If using Linux bridge (virbr0 or custom bridge), ensure VLAN pass-through is enabled:
# Disable IGMP snooping if IPv6 multicast issues occurecho -n 0 > /sys/class/net/virbr0/bridge/multicast_snoopingIn RouterOS, configure bridge VLAN filtering for trunk interfaces:
/interface bridge add name=br1 vlan-filtering=yes/interface bridge port add bridge=br1 interface=ether1/interface bridge vlan add bridge=br1 vlan-ids=10,20 tagged=br1,ether1Troubleshooting
Section titled “Troubleshooting”VM Does Not Start
Section titled “VM Does Not Start”Verify KVM is available:
sudo kvm-ok# Should output: KVM acceleration can be usedCheck for CPU virtualization support:
grep -E 'vmx|svm' /proc/cpuinfo | head -1No Network Connectivity
Section titled “No Network Connectivity”Verify the libvirt default network is active:
sudo virsh net-list --allsudo virsh net-start defaultsudo virsh net-autostart defaultSlow Disk or Network Performance
Section titled “Slow Disk or Network Performance”Check interface driver inside RouterOS:
/interface ethernet print detailIf the driver shows e1000 instead of virtio, shut down the VM and change the NIC model in virt-manager or using virsh edit chr.