RouterOS CLI 極度強大,掌握核心指令即可完成 90% 日常運維:
? # 顯示可用指令與說明
Tab # 自動補全指令/參數
/interface print # 列出所有介面 (ether1, wlan1, bridge1...)
/interface ethernet print
/interface wireless print
/ip address add address=192.168.88.1/24 interface=bridge1
/ip address print
/ip route add dst-address=0.0.0.0/0 gateway=203.0.113.1 # 預設路由
/ip route add dst-address=10.0.0.0/8 gateway=192.168.100.1 # 靜態路由
/ip route print
/ip route add dst-address=0.0.0.0/0 gateway=203.0.113.1,198.51.100.1 check-gateway=ping
# ECMP 等價多路徑,自動分流
# 進階 PCC (Per Connection Classifier) 需配合 mangle 標記連線
/ip firewall filter add chain=input protocol=tcp dst-port=22 action=drop comment="Block SSH from WAN"
/ip firewall filter add chain=forward connection-state=invalid action=drop
/ip firewall filter add chain=forward connection-state=established,related action=accept
/ip firewall filter print
/ip firewall nat add chain=dstnat protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.88.10 to-ports=80 comment="Web Server Port Forward"
/ip firewall nat add chain=srcnat src-address=192.168.88.0/24 dst-address=192.168.88.10 protocol=tcp dst-port=80 action=masquerade comment="Hairpin NAT for Internal Access"
/ip firewall nat print
/interface monitor-traffic ether1,ether2,wlan1 once # 即時流量
/interface monitor-traffic ether1 interval=1 # 持續監控
/ip firewall connection print # 當前連線表
/ip arp print # ARP 表
/user active print # 當前登入用戶 (PPP/VPN/Hotspot)
/system resource print # CPU/記憶體/磁碟/運行時間
/system resource monitor # 即時資源監控
/tool ping 8.8.8.8 count=5 size=64 # Ping 測試
/tool traceroute 8.8.8.8 # 路徑追蹤
/tool sniffer start interface=ether1 filter-ip-address=192.168.88.10 filter-port=80
/tool sniffer packet print
/tool sniffer stop
/tool sniffer save file-name=web_traffic.pcap
# 可下載用 Wireshark 分析
/system backup save name=config_20240115.backup
/file print
# 還原:/system backup load name=config_20240115.backup
# 匯出純文字設定 (可版控):
/export file=config_20240115.rsc
# 還原腳本:/import file=config_20240115.rsc
/system reboot
/system shutdown
/system reset-configuration # 重置為出廠預設 (保留 license)
/system reset-configuration no-defaults=yes skip-backup=yes # 完全清空
/log print
/log print where topics~"error|warning|critical"
/system logging add topics=firewall,debug action=memory
/system logging print
/rest) / API (JSON/HTTP) - 自動化、Ansible/Terraform 整合。RouterOS 指令邏輯一致:/模組 子指令 參數=值。善用 ?、Tab、/export,快速掌握這台功能強大的軟體路由器。