Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

RouterOS (MikroTik) 常用指令速查:介面、IP、防火牆、NAT、監控、備份、嗅探器

編輯:系統常見問題解答

RouterOS CLI 極度強大,掌握核心指令即可完成 90% 日常運維:

基礎操作

?                    # 顯示可用指令與說明
Tab                  # 自動補全指令/參數
/interface print     # 列出所有介面 (ether1, wlan1, bridge1...)
/interface ethernet print
/interface wireless print

IP 位址與路由

/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

多 WAN 負載平衡 (PCC / ECMP)

/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

NAT 映射 (Port Forwarding / Hairpin NAT)

/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

WinBox / WebFig / API 替代

  • WinBox (Windows GUI) - 最常用、圖形化操作、支援 Dude 監控。
  • WebFig (瀏覽器) - 無需安裝、功能完整。
  • REST API (/rest) / API (JSON/HTTP) - 自動化、Ansible/Terraform 整合。

RouterOS 指令邏輯一致:/模組 子指令 參數=值。善用 ?、Tab、/export,快速掌握這台功能強大的軟體路由器。

Copyright © Windows教程網 All Rights Reserved