Networking Lab with MikroTik RouterOS
MikroTik RouterOS is a good, low-cost way to get hands-on with networking concepts without buying physical hardware. This post covers running it as a VM, exposing its WebUI and SSH through a reverse proxy, and connecting to it from the host machine.
Prerequisites
| Component | Version |
|---|---|
| Host OS | Debian GNU/Linux (stable) |
| Hypervisor | VirtualBox |
| RouterOS | MikroTik x86 ISO |
Download the ISO from the MikroTik website.
1. Create the VM
In VirtualBox, create a new VM with type Other/Unknown (64-bit).
- Enable VT-x in system settings
- Attach
mikrotik-7.10.1.isoto the CD drive - Boot and press
ithenEnterto install
2. First Boot
Log in to the console:
user: admin
password: (empty)Request an IP from the internal DHCP server:
/ip dhcp-client add interface=ether1 disabled=no
/ip address printExpected output:
[admin@MikroTik] > ip/address/print
Flags: D - DYNAMIC
Columns: ADDRESS, NETWORK, INTERFACE
# ADDRESS NETWORK INTERFACE
0 D 10.0.2.15/24 10.0.2.0 ether13. Port Forwarding
VirtualBox's NAT network can forward ports from the host to the guest.
| Service | Host IP | Host Port | Guest IP | Guest Port |
|---|---|---|---|---|
| SSH | 127.0.0.1 | 9090 | 10.0.2.15 | 22 |
| WebUI | 127.0.0.1 | 8080 | 10.0.2.15 | 80 |
Traffic hitting localhost:9090 and localhost:8080 now redirects to the guest.
4. Access Methods
Option A: Nginx Reverse Proxy
Create /etc/nginx/conf.d/local_proxy.conf:
server {
listen 80;
server_name webfig.ir;
location / {
proxy_pass http://127.0.0.1:8080/;
}
}sudo nginx -t
sudo systemctl restart nginxAdd to /etc/hosts:
127.0.0.1 webfig.irNow http://webfig.ir reaches the MikroTik WebUI.
Option B: SimpleProxy (No Nginx)
sudo apt install simpleproxy
sudo simpleproxy -L webfig.ir:80 -R 127.0.0.1:8080Option C: SSH
ssh -p 9090 admin@127.0.0.1Add to ~/.ssh/config for convenience:
Host mikrotik
HostName 127.0.0.1
User admin
Port 9090
KexAlgorithms diffie-hellman-group-exchange-sha256Then just:
ssh mikrotikOption D: Winbox via Wine
sudo apt install wine
wine winbox64.exe