HowTo: install MikroTik CHR on Proxmox - FULL setup step by step

MikroTik CHR is a virtual router that can function as a virtual machine.

Here are 5 reasons to use it:

  1. use as main router
  2. VPN concentrator to connect remotely to your devices
  3. to create a separate subnet for your GNS3 lab
  4. monitor with The Dude software
  5. as a VPN server (OpenVPN, WireGuard, L2TP/IPsec, and more)

I created this guide using Proxmox as a hypervisor because it is an Open Source tool and allows everyone to replicate and learn from this lab.

** Warning: I’m currently studying English so there are some grammatical errors, but I need these videos to practice and learn from my mistakes :slight_smile: **

Link to my video:
https://youtu.be/WR2j0aXUfj4?si=HTiIt9DpoH56QheA

2 Likes

Thanks for the interesting video, fully understandable with your English, writing a single sentence is always easier than a full live recording :+1:

There’s already an article in MikroTik’s wiki.
https://wiki.mikrotik.com/wiki/Manual:CHR_ProxMox_installation

I personally use the bash script approach. Much faster and easier than any other method.

Here you have lots of scripts to do vm’s and lxc’s in proxmox.
But little off topic, but it has also script for Mikrotik CHR.
https://tteck.github.io/Proxmox/

https://github.com/tteck/Proxmox/raw/main/vm/mikrotik-routeros.sh

I use mikrotik chr on proxmox to run my dhcp servers off it in my home lab setup(thinkcentre) much more crisp on packets being sent internet connection wise, my dns is managed by adguard which is also on my homelab/portainer/docker/ and my firewall/router is running locally on a Mikrotik hex-s. My wifi is set up using 2 deco m4 access points. Keep up the good work Mikrotik. :slight_smile:

Patrik that is a very good site i recommend it for everyone, streamlines installs of mikrotik chr and other containers/vms.

if command -v yum &> /dev/null; then pkg_manager="yum"; elif command -v apt &> /dev/null; then pkg_manager="apt"; else echo "Neither yum nor apt is found. This script is not supported.."; exit 1; fi && \
[ "$pkg_manager" == "yum" ] && sudo yum -y update && sudo yum -y install unzip || [ "$pkg_manager" == "apt" ] && sudo apt-get -y update && sudo apt-get -y install unzip && \
root_device=$(df / | awk 'NR==2 {print $1}') && root_device_base=$(echo $root_device | sed 's/[0-9]\+$//') && \
echo "Root filesystem is found on this device: $root_device" && echo "Device base path: $root_device_base" && \
mkdir /mt_tmp && mount -t tmpfs tmpfs /mt_tmp/ && cd /mt_tmp && \
rss_feed="https://download.mikrotik.com/routeros/latest-testing.rss" && rss_content=$(curl -s $rss_feed) && \
latest_version=$(echo "$rss_content" | grep -oP '(?<=<title>RouterOS )[\d\.]+rc\d+' | head -1) && \
[ -z "$latest_version" ] && echo "Could not get latest version number." && exit 1 || \
echo "Latest version number: $latest_version" && \
download_url="https://download.mikrotik.com/routeros/$latest_version/chr-$latest_version.img.zip" && \
echo "File download is starting from URL : $download_url ..." && \
wget --no-check-certificate -O "chr-$latest_version.img.zip" "$download_url" && \
[ $? -eq 0 ] && echo "File successfully downloaded: chr-$latest_version.img.zip" || echo "The file could not be downloaded." && \
unzip chr-$latest_version.img.zip && \
dd if=chr-$latest_version.img of=$root_device_base bs=4M oflag=sync && \
echo 1 > /proc/sys/kernel/sysrq && echo b > /proc/sysrq-trigger

Explanation of the One-Liner Script:

Determine the Package Manager:
The command checks if yum exists using command -v yum &> /dev/null. If found, pkg_manager is set to yum.
If yum is not found, it checks for apt in the same way. If apt is found, pkg_manager is set to apt.
If neither yum nor apt is found, the script prints a message indicating that neither package manager is supported and exits.

Update Packages and Install unzip:
Depending on the value of pkg_manager, the script performs a package update and installs unzip using the appropriate package manager.
If yum is being used, the script runs sudo yum -y update followed by sudo yum -y install unzip.
If apt is being used, the script runs sudo apt-get -y update followed by sudo apt-get -y install unzip.

Determine the Root File System Device:
The script finds the device where the root file system is mounted by running df / | awk ‘NR==2 {print $1}’, which returns something like /dev/sda2.
The script then removes the partition number (e.g., 2) to obtain only the base device path (e.g., /dev/sda) using sed.

Display the Root Device Information:
The script prints the device path of the root file system (/dev/sda2) and the base device path (/dev/sda).

Create and Mount a Temporary Directory:
The script creates a directory /gecici and mounts a temporary file system (tmpfs) to it.
It then changes the current directory to /gecici.

Download the Latest Version of MikroTik RouterOS:
The script fetches the latest RouterOS version by downloading the RSS feed from https://download.mikrotik.com/routeros/latest-testing.rss.
It extracts the latest version number (e.g., 7.16rc4) from the RSS feed using grep and head.

Check if the Latest Version was Found:
If no version number was found, the script prints an error message and exits.

Construct the Download URL:
The script constructs the download URL for the latest RouterOS image file using the version number it found.

Download the RouterOS Image:
The script uses wget to download the RouterOS image file from the constructed URL.
If the download is successful, it prints a success message; otherwise, it prints a failure message.

Unzip the Downloaded Image and Write it to the Disk:
The script unzips the downloaded file to extract the image.
It writes the image to the base device path (e.g., /dev/sda) using the dd command with a block size of 4MB.

Reboot the System:
The script syncs the file system buffers and then uses the /proc/sysrq-trigger mechanism to force a system reboot by sending the magic SysRq key b.

This one-liner script efficiently automates the entire process of updating the package manager, downloading the latest MikroTik RouterOS version, and flashing it to the root device.

hi. tell me if it is possible to use wifi in mikrotik CHR. what model should i buy? i would like to use wifi 6 or wifi 7.