全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1266|回复: 4

[经验] 群晖Virtual Machine Manager安装RoutesrOS

[复制链接]
发表于 2022-1-5 22:43:30 | 显示全部楼层 |阅读模式
本帖最后由 fs6738 于 2022-1-10 15:05 编辑

主要思路:VMM安装CentOS7后,dd RouterOS


个人操作,略绕,介意的可以直接centos7 --> ros:

1. 群晖安装Virtual Machine Manager.
2. Ubuntu官网下载完整版ISO镜像Ubuntu18 server //
    安装完成后,ssh登录;如果不能连接,可以vnc手动安装openssh server,重启后连接ssh //
    dd centos7 //

    安装好linux建议先修改为国内dns
  1. echo nameserver 223.5.5.5 > /etc/resolv.conf && echo nameserver 119.29.2
复制代码

3. CentOS7上dd RouterOS
    脚本下载后,解压扔到root下,给予0755权限后运行即可

  1. wget https://www.inkscloud.com/wp-content/uploads/2021/07/1627246350-7e08a36aac8e952.zip
  2. unzip 1627246350-7e08a36aac8e952.zip
  3. chmod +x RouterOS.s && ./RouterOS.sh
复制代码

代码:

  1. #!/bin/bash

  2. # VPS2RouterOS
  3. # https://github.com/Jamesits/vps2routeros
  4. # This script will cause permanent data loss
  5. # Please read the documentation prior to running this
  6. # You have been warned

  7. # ======================= please change these =================================
  8. # your network interface to internet
  9. # this is used to auto configure IPv4 after reboot
  10. # (this may not work for every device)
  11. # eth0 for most devices, ens3 for Vultr
  12. # you can use `ip addr` or `ifconfig` to find out this
  13. # default: the interface on the default route
  14. MAIN_INTERFACE=$(ip route list | grep default | cut -d' ' -f 5)

  15. # HDD device (not partition)
  16. # May not be compatible with SCSI drives; see official document of RouterOS CHR
  17. # you can use `lsblk` to find out this
  18. # default: the disk with a partition mounted to `/`
  19. DISK=$(mount | grep ' / ' | cut -d' ' -f1 | sed 's/[0-9]*$//g')

  20. # get IPv4 address in IP-CIDR format
  21. # do not modify unless you know what you are doing
  22. ADDRESS=$(ip addr show $MAIN_INTERFACE | grep global | cut -d' ' -f 6 | head -n 1)

  23. # get gateway IP
  24. # do not modify unless you know what you are doing
  25. GATEWAY=$(ip route list | grep default | cut -d' ' -f 3)

  26. # URL to RouterOS CHR
  27. ROUTEROS_URL=https://download.mikrotik.com/routeros/6.48.1/chr-6.48.1.img.zip

  28. # Note: you can customize commands to be executed when RouterOS initializes.
  29. # Search `Auto configure script` below
  30. # do not modify that unless you know what you are doing

  31. # ======================= no need to modify below ============================

  32. set -euo pipefail

  33. # check if this script is running under root
  34. if [[ $EUID -ne 0 ]]; then
  35.    echo "This script must be run as root" 1>&2
  36.    exit 1
  37. fi

  38. # https://stackoverflow.com/a/3232082/2646069
  39. confirm() {
  40.     # call with a prompt string or use a default
  41.     read -r -p "${1:-Are you sure? [y/N]} " response
  42.     case "$response" in
  43.         [yY][eE][sS]|[yY])
  44.             true
  45.             ;;
  46.         *)
  47.             false
  48.             ;;
  49.     esac
  50. }

  51. echo -e "Please confirm the settings:"
  52. echo -e "Installation destination: ${DISK}"
  53. echo -e "Network information:"
  54. echo -e "\tinterface: ${MAIN_INTERFACE}"
  55. echo -e "\tIPv4 address: ${ADDRESS}"
  56. echo -e "\tIPv4 gateway: ${GATEWAY}"
  57. echo -e "\nIf you continue, your disk will be formatted and no data will be preserved."

  58. confirm || exit -1

  59. echo "installing packages"
  60. yum -y install wget

  61. echo "download image"
  62. wget ${ROUTEROS_URL} -O chr.img.zip

  63. echo "unzip image"
  64. gunzip -c chr.img.zip > chr.img

  65. echo "mount image"
  66. mount -o loop,offset=512 chr.img /mnt

  67. echo "Get address and gateway and assign variable"

  68. mkdir -p /mnt/rw
  69. \echo "/ip address add address=${ADDRESS} interface=[/interface ethernet find where name=ether1]
  70. /ip route add gateway=${GATEWAY}
  71. " > /mnt/rw/autorun.scr

  72. echo "Unmount the image"
  73. umount /mnt

  74. echo "Your old OS is being wiped while running, good luck"
  75. echo "If the device stopped responding for more than 30 minutes, please issue a reboot manually"

  76. sleep 5

  77. echo "write disk"
  78. echo u > /proc/sysrq-trigger

  79. echo "sync disk"
  80. dd if=chr.img bs=1024 of=${DISK}

  81. echo "wait a while"
  82. sleep 5 || echo "please wait 5 seconds and execute\n\techo b > /proc/sysrq-trigger\nmanually, or hard reset device"

  83. echo "rebooting"
  84. reboot
复制代码


4.winBox搜索局域网找到RouterOS,点击connet连接配置


以上全为借鉴,无任何原创
   https://post.smzdm.com/p/a5dn78pl
   https://www.right.com.cn/forum/forum-72-1.html
   https://www.inkscloud.com/archives/406
   https://www.inkscloud.com/wp-content/uploads/2021/07/1627246350-7e08a36aac8e952.zip[/code]
发表于 2022-1-5 23:04:47 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2022-1-5 22:52:36 | 显示全部楼层
ubuntu DD centos
centos DD ros
我是真不会啊。。我问下。那为啥不直接装centos DD Ros呢?
 楼主| 发表于 2022-1-5 23:29:52 | 显示全部楼层
jiaogeshaminghn 发表于 2022-1-5 23:04
太绕了,没有层次

首先应该是pve

告诉我,为什么要搞个垃圾pve?
服务器装windows不香吗?
 楼主| 发表于 2022-1-5 23:35:31 | 显示全部楼层
生为何故 发表于 2022-1-5 22:52
ubuntu DD centos
centos DD ros
我是真不会啊。。我问下。那为啥不直接装centos DD Ros呢? ...

那你仔细看下第二句话啊
我VMM常备装ubuntu,debian,;但是centos最烂的系统,如果没有必要,当然不安装
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-11-3 05:27 , Processed in 0.063402 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表