一、基礎顯示與系統管理指令
| 指令 | 功能 | 模式 |
show running-config | 顯示當前運行配置 (RAM) | EXEC |
show startup-config | 顯示 NVRAM 啟動配置 | EXEC |
show version | IOS 版本、硬體、記憶體、配置寄存器、啟動時間 | EXEC |
show interfaces [type num] | 介面詳細狀態、計數器、錯誤統計 | EXEC |
show ip interface brief | 所有介面 IP/狀態/協議一覽表 | EXEC |
show controllers [type num] | 介面硬體控制器資訊 (DCE/DTE、纜線、時鐘) | EXEC |
show history | 當前會話指令歷史 | EXEC |
show terminal | 終端機參數 (長寬、分頁) | EXEC |
hostname NAME | 設定主機名 | Global Config |
enable secret PASS | 設定 MD5/SHA256 加密特權密碼 | Global Config |
enable password PASS | 設定舊式明文/弱加密特權密碼 (不建議) | Global Config |
service password-encryption | 啟用所有明文密碼 Type 7 加密顯示 | Global Config |
no ip domain-lookup | 關閉 DNS 查詢 (防誤輸入指令卡住) | Global Config |
banner motd #MSG# | 設定登入橫幅訊息 | Global Config |
copy running-config startup-config | 存檔 (RAM→NVRAM) | EXEC |
write memory | 舊式存檔指令 (等同 copy run start) | EXEC |
erase startup-config | 清除 NVRAM 配置 (慎用) | EXEC |
reload | 重啟路由器 | EXEC |
二、介面與 IP 配置指令
| 指令 | 功能 | 模式 |
interface type num | 進入介面配置模式 | Global Config |
ip address IP MASK [secondary] | 設定主/次要 IP 位址 | Interface Config |
no ip address | 移除 IP 位址 | Interface Config |
ip address dhcp | 介面啟用 DHCP Client 取得 IP | Interface Config |
encapsulation {hdlc|ppp|frame-relay|x25|dot1q VLAN} | 設定封裝格式 | Interface Config |
bandwidth Kbps | 設定介面頻寬參數 (影響路由度量、QoS) | Interface Config |
clock rate bps | DCE 端設定串列時鐘速率 | Interface Config |
shutdown / no shutdown | 關閉/開啟介面 | Interface Config |
description TEXT | 介面描述資訊 | Interface Config |
mtu bytes | 設定 MTU (預設 1500) | Interface Config |
三、靜態與動態路由指令
靜態路由
ip route [vrf NAME] NETWORK MASK {NEXT-HOP-IP | EXIT-INTERFACE} [DISTANCE] [TAG] [PERMANENT] [TRACK OBJ]
ip route 0.0.0.0 0.0.0.0 192.168.1.1 ! 預設路由
ip route 10.0.0.0 255.0.0.0 Serial0/0/0 ! 出介面
ip route 10.0.0.0 255.0.0.0 192.168.1.2 10 ! 浮動靜態路由 AD=10
ip route 10.0.0.0 255.0.0.0 192.168.1.2 track 1 ! 綁定 IP SLA 追蹤
RIPv2
router rip
version 2
network 10.0.0.0
network 192.168.1.0
no auto-summary
passive-interface default
no passive-interface GigabitEthernet0/0
EIGRP (經典/命名模式)
! 經典模式
router eigrp 100
network 10.0.0.0 0.255.255.255
network 192.168.1.0 0.0.0.255
no auto-summary
eigrp router-id 1.1.1.1
passive-interface default
no passive-interface GigabitEthernet0/0
! 命名模式 (IOS 15.0+ 推薦)
router eigrp NAME
address-family ipv4 autonomous-system 100
af-interface default
passive-interface
exit-af-interface
af-interface GigabitEthernet0/0
no passive-interface
exit-af-interface
topology base
offset-list 0 in 100
exit-af-topology
network 10.0.0.0 0.255.255.255
network 192.168.1.0 0.0.0.255
eigrp router-id 1.1.1.1
exit-address-family
OSPFv2
router ospf 1
router-id 1.1.1.1
network 192.168.1.0 0.0.0.255 area 0
network 10.1.1.0 0.0.0.255 area 0
passive-interface default
no passive-interface GigabitEthernet0/0
auto-cost reference-bandwidth 100000 ! 參考頻寬 100Gbps
default-information originate always ! 宣告預設路由
area 1 stub no-summary ! Totally Stubby Area
OSPFv3 (IPv6)
ipv6 unicast-routing
router ospfv3 1
router-id 1.1.1.1
address-family ipv4 unicast
area 0 normal
redistribute connected
exit-address-family
address-family ipv6 unicast
area 0 normal
redistribute connected
exit-address-family
!
interface GigabitEthernet0/0
ospfv3 1 ipv4 area 0
ospfv3 1 ipv6 area 0
BGP
router bgp 65001
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 192.168.1.2 remote-as 65002
neighbor 192.168.1.2 description ISP-UPLINK
address-family ipv4 unicast
network 10.0.0.0 mask 255.0.0.0
neighbor 192.168.1.2 activate
neighbor 192.168.1.2 soft-reconfiguration inbound
exit-address-family
四、VLAN 與 Trunk 配置 (路由器子介面/三層交換)
| 指令 | 功能 | 模式 |
interface GigabitEthernet0/0.10 | 建立子介面 (Router-on-a-Stick) | Global Config |
encapsulation dot1Q 10 | 綁定 VLAN 10 (802.1Q) | Subinterface |
ip address 192.168.10.1 255.255.255.0 | 設定閘道 IP | Subinterface |
vlan 10 | 建立 VLAN (三層交換/新語法) | Global Config |
name SERVERS | VLAN 命名 | VLAN Config |
interface Vlan10 | 建立 SVI (三層交換) | Global Config |
ip address 192.168.10.1 255.255.255.0 | SVI IP 位址 | SVI Config |
switchport mode trunk | 設定 Trunk 埠 | Interface Config |
switchport trunk allowed vlan 10,20,30 | 允許的 VLAN 列表 | Interface Config |
switchport access vlan 10 | 設定 Access 埠 VLAN | Interface Config |
spanning-tree portfast | Access 埠啟用 PortFast | Interface Config |
五、VTP (VLAN Trunking Protocol) 配置
vtp mode server ! Server/Client/Transparent/Off
vtp domain CORP-DOMAIN
vtp password VtpP@ssw0rd
vtp version 3 ! 支援擴展 VLAN、私有 VLAN、密碼加密
! 驗證
show vtp status
show vtp counters
六、生成樹協議 (STP/RSTP/MSTP)
spanning-tree mode rapid-pvst ! RSTP per-VLAN (推薦)
spanning-tree mode mst ! MSTP 多實例
spanning-tree vlan 10 priority 4096 ! 設定 Root Bridge 優先權 (0-61440, 4096 倍數)
spanning-tree portfast default ! 全域啟用 PortFast (僅 Access 埠)
spanning-tree bpduguard default ! 全域啟用 BPDU Guard
show spanning-tree vlan 10 detail
七、NAT/PAT 配置
! 靜態 NAT
ip nat inside source static 192.168.1.10 203.0.113.10
! 動態 PAT (過載)
access-list 1 permit 192.168.1.0 0.0.0.255
ip nat inside source list 1 interface GigabitEthernet0/0 overload
! 介面標記
interface GigabitEthernet0/0
ip nat outside
interface GigabitEthernet0/1
ip nat inside
! 驗證
show ip nat translations
show ip nat statistics
八、DHCP Server/Relay
! DHCP Server
ip dhcp excluded-address 192.168.10.1 192.168.10.10
ip dhcp pool LAN-POOL
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
dns-server 8.8.8.8 168.95.1.1
lease 7
!
! DHCP Relay
interface GigabitEthernet0/1
ip helper-address 192.168.1.10
九、AAA 與 SSH 安全配置
aaa new-model
aaa authentication login default group tacacs+ local
aaa authorization commands 15 default group tacacs+ local
aaa accounting exec default start-stop group tacacs+
aaa accounting commands 15 default start-stop group tacacs+
!
ip domain-name corp.local
crypto key generate rsa modulus 2048
ip ssh version 2
ip ssh time-out 60
ip ssh authentication-retries 3
!
line vty 0 15
login authentication default
transport input ssh
exec-timeout 15 0
logging synchronous
十、NTP、Syslog、SNMPv3
! NTP
ntp server 162.159.200.123 prefer
ntp source Loopback0
! Syslog
logging host 192.168.1.50 transport udp port 514
logging trap notifications
logging source-interface Loopback0
logging buffered 65536
! SNMPv3
snmp-server group NETWORK-GROUP v3 auth priv
snmp-server user NETWORK-USER NETWORK-GROUP v3 auth sha AuthP@ss priv aes PrivP@ss
snmp-server enable traps config snmp linkdown linkup coldstart warmstart
snmp-server host 192.168.1.50 version 3 auth NETWORK-USER udp-port 162
十一、IPv6 基礎配置
ipv6 unicast-routing
interface GigabitEthernet0/0
ipv6 address 2001:DB8:1::1/64
ipv6 enable
!
interface GigabitEthernet0/1
ipv6 address 2001:DB8:2::1/64
ipv6 enable
!
ipv6 route ::/0 2001:DB8:1::2
!
! OSPFv3 見上文
! 驗證
show ipv6 interface brief
show ipv6 route
show ipv6 neighbors
結語
本速查表涵蓋思科路由器日常運維 90% 以上高頻指令。建議:
1. 依職責建立個人/團隊「指令卡片」 (Anki/Notion/OneNote/Markdown)。
2. 實驗環境逐條實測,理解輸出含義與副作用。
3. 納入自動化腳本模板 (Jinja2/Ansible/Netmiko),以代碼管理配置。
4. 定期審查廢棄/變更指令 (如 vlan database 已棄用,改 vlan config/vlan NUM),保持知識庫與現行 IOS 版本同步。