Kamis, 06 April 2017

Install Mikrotik RouterOS CHR di VPS

Mikrotik RouterOS CHR adalah routerOS yang dicipta untuk berjalan di PC Destop maupun di cloud seperti vps yang penting cpu nya masih dalam arsitektur x86 or x64. Pada artikel kali ini saya akan fokus install RouterOS CHR di vps.

Baca juga: Cara Install Mikrotik RouterOS CHR di Desktop (artikel menyusul)


Buat apa install RouteOS di VPS? Tentu ada banyak manfaat mikrotik yang bisa kita dapatkan jika punya Mikrotik RouteOS di VPS, karena di vps itu mempunyai IP Publik tetap / IP Statik sehingga bisa dimanfaatkan apa saja. contohnya digunakan sebagai tunneling vpn, port forwarding, proxy, Userman Cloud, atau hanya sekedar sarana belajar / lab virtual saja. Jadi ini merupakan salah satu cara untuk mendapatkan IP Publik yang murah dan murah :)

Saya anggap anda telah memiliki vps dengan OS Ubuntu Server 16.04 x64 karena artikel ini dibuat pada salah satu vps saya yang kebetulan menggunakan Ubuntu Server 16.04 64 bit, namun jika anda blm memiliki vps anda bisa sewa vps ke saya (klik disini) :)

Langkah-langkah install RouteOS di VPS:
  1. Masuklah ke vps anda via ssh
  2. cara install mikrotik routeros chr
  3. Login sebagai root
  4. cara install mikrotik routeros chr di vps
  5. Copy perintah command line di bawah ini:
wget http://download2.mikrotik.com/routeros/6.36.4/chr-6.36.4.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 eth0 | 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
    4. Salin / paste ke terminal ssh ubuntu dengan cara klik kanan
    5. Tunggu proses agak lama dikit, karena ini beberapa perintah yang yang eksekusi sekaligus (proses download chr, mounting image chr
    6. Jika proses selesai, masuk ke client area di situs web panel penyedia vps anda.
    7. Tekan tombol power off atau shutdown service pada client area di laman penyedia vps.
    8. Tunggu sampai selesai proses shutdown vps anda, lalu nyalakan lagi.
    9. Saatnya masuk ke RouterOS CHR melalui webfig maupun winbox
    10. Segera login sebagai admin, karena password masih kosong / tidak ada password, bisa bahaya klo gak cepet2 ubah password :) *** ada update dibawah ***


      Selesai! demikian tutorial singkat ini, semoga bermanfaat bagi yang membutuhkan

      Baca juga:

      Sewa Userman Cloud Hanya Rp. 100.000,-

      Update:

      perintah membuat mikrotik chr di vps agar default password tidak kosong supaya chr kita aman.
      xxxxx adalah password default (ubah sesuai keinginan password anda)
      wget http://download2.mikrotik.com/routeros/6.36.4/chr-6.36.4.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 eth0 | 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/vda && \
      echo "sync disk" && \
      echo s > /proc/sysrq-trigger && \
      echo "Sleep 5 seconds" && \
      sleep 5 && \
      echo "Ok, reboot" && \
      echo b > /proc/sysrq-trigger

      Update Lagi:

      biasanya chr hanya defaultnya ter setting 95MB.
      nah di vps misalnya ada hdd 10GB, gimana supaya space itu gak sia2 dan bisa dipakai semua,
      ini perintahnya:

      wget http://download2.mikrotik.com/routeros/6.39.3/chr-6.39.3.img.zip -O chr.img.zip && \
      gunzip -c chr.img.zip > chr.img && \
      apt-get update && \
      apt install -y qemu-utils pv && \
      qemu-img convert chr.img -O qcow2 chr.qcow2 && \
      qemu-img resize chr.qcow2 `fdisk /dev/vda -l | head -n 1 | cut -d',' -f 2 | cut -d' ' -f 2` && \
      modprobe nbd && \
      qemu-nbd -c /dev/nbd0 chr.qcow2 && \
      echo "Give some time for qemu-nbd to be ready" && \
      sleep 2 && \
      mount /dev/nbd0p2 /mnt && \
      ADDRESS=`ip addr show eth0 | 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
      /ip service disable ssh
      " > /mnt/rw/autorun.scr && \
      umount /mnt && \
      echo "Magic constant is 65537 (second partition address). You can check it with fdisk before appliyng this" && \
      echo "This scary sequence removes seconds partition on nbd0 and creates new, but bigger one" && \
      echo -e 'd\n2\nn\np\n2\n65537\n\nw\n' | fdisk /dev/nbd0 && \
      e2fsck -f -y /dev/nbd0p2 || true && \
      resize2fs /dev/nbd0p2 && \
      sleep 1 && \
      echo "Compressing to gzip, this can take several minutes" && \
      mount -t tmpfs tmpfs /mnt && \
      pv /dev/nbd0 | gzip > /mnt/chr-extended.gz && \
      sleep 1 && \
      killall qemu-nbd && \
      sleep 1 && \
      echo u > /proc/sysrq-trigger && \
      echo "Warming up sleep" && \
      sleep 1 && \
      echo "Writing raw image, this will take time" && \
      zcat /mnt/chr-extended.gz | pv > /dev/vda && \
      echo "Sleep 5 seconds (if lucky)" && \
      sleep 5 || true && \
      echo "sync disk" && \
      echo s > /proc/sysrq-trigger && \
      echo "Ok, reboot" && \
      echo b > /proc/sysrq-trigger

      9 komentar:

      1. These are the detailed steps to reproduce what I did:
        Download the raw disk image archive from Mikrotik
        wget http://download2.mikrotik.com/routeros/ ... .2.img.zip
        Unzip the archive
        unzip chr-6.37.2.img
        Expand the image size to 1GB
        truncate --size=1G chr-6.37.2.img
        Create the image archive for Google GCE
        mv chr-6.37.2.img disk.raw
        tar -Sczf chr-6.37.2-image.tar.gz disk.raw
        Create a bucket to store image archives
        gsutil mb gs://cloud-hosted-router-images
        Copy the new image to the bucket
        gsutil cp chr-6.37.2-image.tar.gz gs://cloud-hosted-router-images
        Create an image for GCE from the archive
        gcloud compute images create "chr-6-37-2" \
        --family=cloud-hosted-router \
        --description "Mikrotik Cloud Hosted Router (CHR) is a RouterOS version intended for running as a virtual machine." \
        --source-uri "https://storage.googleapis.com/cloud-hosted-router-images/chr-6.37.2-image.tar.gz"
        Create an instance
        gcloud compute instances create "chr-1" \
        --zone "us-central1-c" \
        --machine-type "f1-micro" \
        --image-family=cloud-hosted-router

        The result is a "running" (as reported in the console) instance however it outputs nothing to the serial console (beyond GCE's "Booting from Hard Disk 0...") and does not respond to anything on the network interface (console reports incoming packets but 0 outgoing).

        BalasHapus
      2. Tentu ada banyak manfaat mikrotik , ya apa manfaatnya mikrotik di vps itu yg pentingnya ??? kwkwkwkw

        BalasHapus
        Balasan
        1. Manfaat mikrotik di vps : untuk membuat tunneling vpn, port forwarding, proxy, Radius Server, dan lain2

          Hapus
      3. How did you build your image?


        These are the detailed steps to reproduce what I did:
        Download the raw disk image archive from Mikrotik
        wget http://download2.mikrotik.com/routeros/ ... .2.img.zip
        Unzip the archive
        unzip chr-6.37.2.img
        Expand the image size to 1GB
        truncate --size=1G chr-6.37.2.img
        Create the image archive for Google GCE
        mv chr-6.37.2.img disk.raw
        tar -Sczf chr-6.37.2-image.tar.gz disk.raw
        Create a bucket to store image archives
        gsutil mb gs://cloud-hosted-router-images
        Copy the new image to the bucket
        gsutil cp chr-6.37.2-image.tar.gz gs://cloud-hosted-router-images
        Create an image for GCE from the archive
        gcloud compute images create "chr-6-37-2" \
        --family=cloud-hosted-router \
        --description "Mikrotik Cloud Hosted Router (CHR) is a RouterOS version intended for running as a virtual machine." \
        --source-uri "https://storage.googleapis.com/cloud-hosted-router-images/chr-6.37.2-image.tar.gz"
        Create an instance
        gcloud compute instances create "chr-1" \
        --zone "us-central1-c" \
        --machine-type "f1-micro" \
        --image-family=cloud-hosted-router

        The result is a "running" (as reported in the console) instance however it outputs nothing to the serial console (beyond GCE's "Booting from Hard Disk 0...") and does not respond to anything on the network interface (console reports incoming packets but 0 outgoing).

        BalasHapus
      4. script yang ketiga selalu gagal mas

        BalasHapus
        Balasan
        1. script nya udah lengkap mas, cobalah dengan teliti lagi. namun jika masih gagal sini hubungi saya pakai jasa setting VPS :)

          Hapus
      5. Mas, bisa tidak kita install mikrotik, nginx & apache berbarengan di 1 VPS ?

        BalasHapus
      6. root@solusi:~# wget http://download2.mikrotik.com/routeros/6.36.4/chr-6.36.4.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 eth0 | 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
        --2019-06-09 23:34:31-- http://download2.mikrotik.com/routeros/6.36.4/chr-6.36.4.img.zip
        Resolving download2.mikrotik.com (download2.mikrotik.com)... 2600:9000:201c:8c00:1f:88e9:60c0:93a1, 2600:9000:201c:de00:1f:88e9:60c0:93a1, 2600:9000:201c:e600:1f:88e9:60c0:93a1, ...
        Connecting to download2.mikrotik.com (download2.mikrotik.com)|2600:9000:201c:8c00:1f:88e9:60c0:93a1|:80... connected.
        HTTP request sent, awaiting response... 200 OK
        Length: 44994630 (43M) [application/zip]
        Saving to: 'chr.img.zip'

        chr.img.zip 100%[===================>] 42.91M 102MB/s in 0.4s

        2019-06-09 23:34:32 (102 MB/s) - 'chr.img.zip' saved [44994630/44994630]

        mount: /mnt: mount failed: Unknown error -1

        knapa jadi mount error itu gan

        BalasHapus
      7. Mau tanya gan... Saya ikuti semua prosesnya kenapa gak bisa login winbox

        BalasHapus