X

How To Convert Ubuntu 19.04 Server To MikroTik Router Using Script

MikroTik is the best router so I want to share how to convert Ubuntu 19.04 server to the MikroTik router using script. MikroTik router easy manages from winbox client soft. Remember if you use this script on your laptop then can’t get back previous operating system. So be careful using this guide. This guide for using mainly vps or virtual system, not for use physical server.

How To Add Windows Host In Zabbix Server
Monitor mysql Service In My Zabbix Server

MikroTik chr version : 6.44.6

Ubuntu version : 19.04

MikroTik default user : admin

MikroTik default password : don’t needed

Step #01: Check my ubuntu server like version & ip using below command.

root@Ubuntu-16:~# lsb_release -a
No LSB modules are available.
Distributer ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial

Step #02: Open script file and copy my provided script

vi script.sh

#!/bin/bash
wget https://download.mikrotik.com/routeros/6.44.6/chr-6.44.6.img.zip -O chr.img.zip  && \
gunzip -c chr.img.zip > chr.img  && \
mount -o loop,offset=512 chr.img /mnt && \
ADDRESS=`ip addr show eth1 | 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
/ip service disable telnet
/user set 0 name=root password=xxxxxx
 " > /mnt/rw/autorun.scr && \
umount /mnt && \
echo u > /proc/sysrq-trigger && \
dd if=chr.img bs=1024 of=/dev/xvda && \
echo "sync disk" && \
echo s > /proc/sysrq-trigger && \
echo "Sleep 5 seconds" && \
sleep 5 && \
echo "Ok, reboot" && \
echo b > /proc/sysrq-trigger

Then press Esc :wq then press Enter for save file.

Step #03: If your server disk name xvda so not needed any change script.

Check your server disk name using below command.

root@Ubuntu-16:~# lsblk

when you see disk is xvda so it is fine not change from script. But if you see another disk name so must be change it.

If you see any problem please see my YouTube channel for more details.

 

5 1 vote
Article Rating
Admin: I am system administrator as Windows and Linux platform. I have 4 years skilled from the professional period. I have to configure Linux based system such as an Asterisk VOIP system, Network monitoring tools (ZABBIX), Virtualization (XEN Server), Cloud computing (Apache CloudStack) etc. Now share my professional skill each interested person. Thanks to all.

View Comments (10)

Leave a Comment