Install MikroTik CHR on VPS

From KG7QIN's Wiki
Revision as of 17:36, 7 July 2024 by Kg7qin (talk | contribs) (Added note)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Misc notes on installing a MiktoTik CHR on a VPS

Install

Spin up VPS with some Debian based Linux distro and login. Then run the following to replace the install with a MikroTik CHR:

Note: Replace the chr-6.40.1.img.zip with the version of Mikrotik's CHR that you wish to use.

apt-get install unzip
wget https://download2.mikrotik.com/routeros/6.40.1/chr-6.40.1.img.zip -O chr.img.zip && \
gunzip -c chr.img.zip > chr.img && \ 
mount -o loop,offset=33554944 chr.img /mnt && \ 
ADDRESS=`ip addr show ens3 | grep global | cut -d' ' -f 6 | head -n 1` && \ 
GATEWAY=`ip route list | grep default | cut -d' ' -f 3` && \ 
echo "/ip address add address=$ADDRESS interface=[/interface ethernet find where name=ether1] /ip route add gateway=$GATEWAY " > /mnt/rw/autorun.scr && \ 
umount /mnt && \ 
echo u > /proc/sysrq-trigger && \ dd if=chr.img bs=1024 of=/dev/vda && \
reboot
  • Once done you should have the system power off and then back on to reboot into the MikroTik CHR

Config Networking on CHR

Set $ADDRESS and $GATEWAY first or replace them in the line below (as it appears in the script above) with the actual values

echo "/ip address add address=$ADDRESS interface=[/interface ethernet find where name=ether1] /ip route add gateway=$GATEWAY