X

How To Convert Centos 7 Server To MikroTik Router Using Script

In this tutorial how to convert Centos 7 server to MikroTik router using bash script. MikroTik is a popular router for every ISP. MikroTik provides many installation process like iso, image file, chr and more. So in this tutorial using chr  image.

How To Setup ZFS Storage Pool On Ubuntu 14.04
How To Add Windows Host In Zabbix Server

Step #01: Check server operating system version using below command.

[root@localhost ~]# cat /etc/redhat-release

Then check ip address using below command.

[root@localhost ~]# ip r

Step #02: create script.sh file and insert command.

[root@localhost ~]# vi script.sh

Now insert below all lines into this file.

#!/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 type :wq then press Enter for save file.

Remember : Must be change eth1 and /dev/xvda as your own server interface name and disk name otherwise not properly install this script.

Check your server disk name

[root@localhost ~]# lsblk

Check your server interface name using below command.

[root@localhost ~]# ip a

Then see your interface name.

If any error so please see my YouTube channel for more videos.

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 (4)

Leave a Comment