🧰 Cisco 基本使用方式教學(CLI 指令入門)
Cisco CLI(Command Line Interface) 是所有網路工程師必備的操作環境, 透過命令列可進行網路設備的設定、除錯與管理。 本文將介紹 Cisco 路由器與交換器的基本操作方式、模式切換與常見指令。
📘 一、CLI 模式說明
Cisco 裝置的操作模式分為數個層級:
| 模式 | 提示符號 | 用途說明 |
|---|---|---|
| User EXEC | > | 基本監看模式,僅能查看狀態。 |
| Privileged EXEC | # | 具管理權限,可執行進階指令。 |
| Global Configuration | (config)# | 進入全域設定模式。 |
| Interface Configuration | (config-if)# | 針對指定介面設定。 |
模式切換範例:
Router> enable Router# configure terminal Router(config)# interface gigabitEthernet 0/0 Router(config-if)# exit Router(config)# end Router#
⚙️ 二、基本操作指令
- 檢視系統資訊:
show version
show interfaces status
show running-config
copy running-config startup-config
show ip route
🌐 三、基本網路設定範例
Router> enable Router# configure terminal ! 設定主機名稱 Router(config)# hostname R1 ! 設定介面 IP R1(config)# interface gigabitEthernet 0/0 R1(config-if)# ip address 192.168.10.1 255.255.255.0 R1(config-if)# no shutdown ! 設定預設路由 R1(config)# ip route 0.0.0.0 0.0.0.0 192.168.10.254 ! 儲存設定 R1# copy running-config startup-config
💡 提示:
執行 no shutdown 以啟用介面,否則埠將維持關閉狀態。
🔐 四、安全性與使用者管理
! 建立本機帳號 R1(config)# username admin privilege 15 secret Cisco123 ! 設定 Console 密碼 R1(config)# line console 0 R1(config-line)# password 1234 R1(config-line)# login ! 設定 VTY (Telnet/SSH) 登入 R1(config)# line vty 0 4 R1(config-line)# password 1234 R1(config-line)# login
若要啟用 SSH,需先設定主機名稱與網域名稱,並產生 RSA 金鑰:
R1(config)# hostname R1 R1(config)# ip domain-name example.com R1(config)# crypto key generate rsa modulus 2048
🧭 五、除錯與監控指令
- 即時觀察封包:
debug ip packet detail
show interfaces gigabitEthernet 0/0
ping 192.168.20.1
traceroute 8.8.8.8
使用完除錯後,務必關閉所有 debug 功能:
undebug all
📘 結語
Cisco CLI 是理解網路運作的核心。 熟悉各模式與常見指令後,能快速完成設定、除錯與維運。 若進一步搭配 show 系列指令與 logging 監控, 即可建立穩定且可追蹤的網路環境。
🔗 延伸閱讀
— WWFandy・系統與網路筆記
沒有留言: