联系

MikroTik RouterOS 在 VirtualBox 中:完整 CHR 设置

首页 / 博客

4 分钟阅读
ZILL E ALI11 月 6, 2026教程

运行 VirtualBox 中的 MikroTik RouterOS 为您提供一个免费的实验室,用于 PPPoE、VLAN、队列、防火墙和路由实践,无需购买硬件。完成此任务的工具是云托管路由器(CHR),即 MikroTik 为虚拟化平台构建的 x86 镜像。本指南涵盖虚拟机的设置、实际可用的适配器设置、使用 Winbox 的首次访问,以及一个可扩展用于 MTCNA 和 MTCRE 实践的双路由器实验。

为什么在 MikroTik RouterOS VirtualBox 实验中使用 CHR

  • 与 CCR 和 hAP 设备上相同的 RouterOS v7,命令可直接迁移到生产环境。
  • 快照让您可以在几秒钟内破坏配置并回滚。
  • 克隆一台虚拟机,即可获得第二台用于路由或 PPPoE 客户端/服务器实验的路由器。

免费许可证将每个接口的上传速率限制为 1 Mbps,这对配置练习而言并不重要。

先决条件

  • Windows、Linux 或 macOS(Intel)上的 VirtualBox 7.x
  • 每台路由器 256 MB RAM 和 1 个 vCPU
  • 主机上的 Winbox 4
  • CHR 本体 VDI 来自 mikrotik.com/download 的镜像(稳定通道)

创建虚拟机

  1. 解压下载的 zip 以获取 chr-7.x.vdi.
  2. 新虚拟机:类型 其他,版本 其他/未知(64 位),256 MB RAM。
  3. 选择 使用现有的虚拟硬盘 并选择该 VDI。
  4. 在“系统”设置中,禁用启动顺序中的软盘。关闭 EFI。

在挂载之前为每个路由器复制一次 VDI,或使用 VirtualBox 克隆,这样每个虚拟机都有独立的磁盘。

实验的最佳网络适配器设置

此部分决定实验是否能正常运行。

适配器 连接到 用途
适配器 1 NAT 路由器的互联网访问(ether1,WAN)
适配器 2 仅主机 从您的电脑使用 Winbox 和 SSH(ether2)
适配器 3 内部网络 lab-link1 链接到其他实验室路由器(ether3)

使用 Intel PRO\/1000 MT Desktop 或 准虚拟化(virtio-net) 作为适配器类型。将混杂模式设置为 全部允许 在 Host-Only 和 Internal 适配器上,如果您计划桥接或运行 VLAN。

仅当您希望路由器位于真实局域网时,才使用桥接而非 NAT。

首次启动并访问 RouterOS

在控制台登录为 admin 使用空密码。RouterOS v7 会强制您立即设置新密码。

获取 WAN 地址并检查接口列表:

\/ip dhcp-client add interface=ether1\n\/interface print\n\/ip address print

在主机上打开 Winbox。虚拟机出现在 邻居 通过 Host-Only 适配器。先通过 MAC 连接,然后分配管理 IP:

\/ip address add address=192.168.56.10\/24 interface=ether2

首小时配置

\/system identity set name=lab-r1\n\/user add name=zill group=full password=\"change-me\"\n\/ip service disable telnet,ftp,api,api-ssl\n\/ip dns set servers=1.1.1.1,8.8.8.8 allow-remote-requests=no\n\/system ntp client set enabled=yes servers=pool.ntp.org\n\/ip firewall nat add chain=srcnat out-interface=ether1 action=masquerade

立即创建快照。这是您的干净基线。

构建一个简单的双路由器实验室

Mikrotik RouterOS VirtualBox CHR lab topology: NAT connects to Router 1, Host-Only provides Winbox management, and an Internal Network links both routers.

克隆 lab-r1 为 lab-r2 并选择 为所有网络适配器生成新的 MAC 地址. 如果不这样做,两台路由器会共享 MAC,导致链路异常。

在 r1 上:

\/ip address add address=10.0.12.1\/30 interface=ether3

在 r2 上:

\/system identity set name=lab-r2\n\/ip address add address=10.0.12.2\/30 interface=ether3\n\/ip route add dst-address=0.0.0.0\/0 gateway=10.0.12.1\n\/ping 10.0.12.1 count=3

从这里,将 r1 转为 PPPoE 服务器,r2 转为客户端,以演练以下设置 使用 FreeRADIUS 的 PPPoE, 或使用 热点桥接模式指南.

常见错误及修复

  • Winbox 未显示邻居: 管理适配器为 NAT。请切换为 Host-Only。
  • 两台路由器无法 ping: 内部网络名称不同,或克隆的 MAC 未重新生成。
  • No internet from the router: ether1 has no DHCP client, or the default route is missing.
  • VLANs do not pass: set Promiscuous Mode to Allow All on the adapter.
  • VM does not boot: EFI is enabled or the disk was attached as the wrong controller. Use SATA or IDE with EFI off.

结论

A MikroTik RouterOS VirtualBox lab costs nothing and takes about fifteen minutes to build. CHR gives you real RouterOS v7, NAT gives it internet, Host-Only gives you Winbox, and Internal Networks link routers together. Snapshot the clean baseline, then break things freely. Once the two-router lab works, add a third router for OSPF, or move the same topology into Proxmox as described in the ISP monitoring stack guide.

作者

ZILL E ALI

拥有 MTCNA 和 MTCRE 认证的网络工程师、ISP 基础设施专家,Developer Zon 创始人。在此撰写关于 MikroTik、Cisco、ISP 基础设施以及偶尔的构建日志。

留下回复

本站使用 Akismet 来减少垃圾评论。了解您的评论数据如何被处理。