(1)模式轉(zhuǎn)換命令
用戶模式----特權(quán)模式,使用命令"enable"
特權(quán)模式----全局配置模式,使用命令"config t"
全局配置模式----接口模式,使用命令"interface+接口類型+接口號(hào)" 全局配置模式----線控模式,使用命令"line+接口類型+接口號(hào)" 注:
用戶模式:查看初始化的信息. 特權(quán)模式:查看所有信息、調(diào)試、保存配置信息
全局模式:配置所有信息、針對(duì)整個(gè)路由器或交換機(jī)的所有接口
接口模式:針對(duì)某一個(gè)接口的配置
線控模式:對(duì)路由器進(jìn)行控制的接口配置
(2)基本配置命令
show命令
show running config 顯示所有的配置
show versin 顯示版本號(hào)和寄存器值
show interface+接口類型+接口號(hào) 查看接口管理性
show controllers interface 查看接口是否有 DCE 電纜
show history 查看歷史記錄
show terminal 查看終端記錄大小
show ip interface brief 查看接口的謫要信息
show spamming-tree vlan +vlan 號(hào) 查看 VLA 怕生成樹(shù)議
接口配置
shut down 關(guān)閉接口
no shutdown 打開(kāi)接口
ip add +ip 地址 配置 IP 地址
secondary+IP 地址 為接口配置第二個(gè) IP 地址
hostname+主機(jī)名 配置路由器或交換機(jī)的標(biāo)識(shí)
config memory 修改保存在 NVRAM 中的啟動(dòng)配置
exec timeout 0 0 設(shè)置控制臺(tái)會(huì)話超時(shí)為 0
no ip address 刪除已配置的 IP 地址
密碼設(shè)置
service password-encryptin 手工加密所有密碼
enable password +密碼 配置明文密碼
ena sec +密碼 配置密文密碼
line vty 0 4/15 進(jìn)入 telnet 接口
password +密碼 配置 telnet 密碼
line aux 0 進(jìn)入 AUX 接口
password +密碼 配置密碼
line con 0 進(jìn)入 CON 接口
password +密碼 配置密碼
bandwidth+數(shù)字 配置帶寬
在 Cisco 設(shè)備上修改控制端口密碼:
R1(config)# line console 0
R1(config-line)# login
R1(config-line)# password Lisbon
R1(config)# enable password Lilbao
R1(config)# login local
R1(config)# username student password cisco
在 Cisco 設(shè)備上設(shè)置控制臺(tái)及 vty 端口的會(huì)話超時(shí):
R1(config)# line console 0
R1(config-line)# exec-timeout 5 10
R1(config)# line vty 0 4
R1(config-line)# exec-timeout 5 2
NVRAM
show startup config 查看 NVRAM 中的配置信息
copy run-config atartup config 保存信息到 NVRAM
write 保存信息到 NVRAM
erase startup-config 清除 NVRAM 中的配置信息
description+信息 配置接口聽(tīng)描素信息
提示語(yǔ)
banner motd # +信息 + # 配置路由器或交換機(jī)的描素信息
vlan
vlan database 進(jìn)入 VLAN 數(shù)據(jù)庫(kù)模式
vlan +vlan 號(hào)+ 名稱 創(chuàng)建 VLAN
switchport access vlan +vlan 號(hào) 為 VLAN 為配接口
interface vlan +vlan 號(hào) 進(jìn)入 VLAN 接口模式
ip add +ip 地址 為 VLAN 配置管理 IP 地址
VTP 中繼
vtp+service/tracsparent/client 配置 SW 的 VTP 工作模式
vtp +domain+域名 配置 SW 的 VTP 域名
vtp +password +密碼 配置 SW 的密碼
switchport mode trunk 啟用中繼
no vlan +vlan 號(hào) 刪除 VLAN
(3)路由器配置命令
ip route+非直連網(wǎng)段+子網(wǎng)掩碼+下一跳地址 配置靜態(tài)/默認(rèn)路由
show ip route 查看路由表
show protocols 顯示出所有的被動(dòng)路由協(xié)議和接口上哪些協(xié)議被設(shè)置
show ip protocols 顯示了被配置在路由器上的路由選擇協(xié)議
show ip eigrp neighbors 查看鄰居表
show ip eigrp topology 查看拓?fù)浔?br>
show ip eigrp traffic 查看發(fā)送包數(shù)量
show ip ospf 顯示 OSPF 的進(jìn)程號(hào)和 ROUTER-ID
show user 查看 SW 的在線用戶
router rip 激活 RIP 協(xié)議
network +直連網(wǎng)段 發(fā)布直連網(wǎng)段
interface lookback 0 激活邏輯接口
passive-interface +接口類型+接口號(hào) 配置接口為被動(dòng)模式
debug ip +協(xié)議 動(dòng)態(tài)查看路由更新信息
undebug all 關(guān)閉所有 DEBUG 信息
router eigrp +as 號(hào) 激活 EIGRP 路由協(xié)議
network +網(wǎng)段+子網(wǎng)掩碼 發(fā)布直連網(wǎng)段
router ospf +process-ID 激活 OSPF 協(xié)議
network+直連網(wǎng)段+area+區(qū)域號(hào) 發(fā)布直連網(wǎng)段
encapsulation+封裝格式 更改封裝格式
no ip admain-lookup 關(guān)閉路由器的域名查找
ip routing 在三層交換機(jī)上啟用路由功能
clear line +線路號(hào) 清除線路
(4) 三層交換機(jī)配置命令
配置一組二層端口
configure terminal 進(jìn)入配置狀態(tài)
nterface range {port-range} 進(jìn)入組配置狀態(tài)
配置三層端口
configure terminal 進(jìn)入配置狀態(tài)
interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {portchannel
port-channel-number} 進(jìn)入端口配置狀態(tài)
no switchport 把物理端口變成三層口
ip address ip_address subnet_mask 配置 IP 地址和掩碼
no shutdown 激活端口
例:
Switch(config)# interface gigabitethernet0/2
Switch(config-if)# no switchport
Switch(config-if)# ip address 192.20.135.21 255.255.255.0
Switch(config-if)# no shutdown
配置 VLAN
configure terminal 進(jìn)入配置狀態(tài)
vlan vlan-id 輸入一個(gè) VLAN 號(hào), 然后進(jìn)入 vlan 配態(tài),可以輸入一個(gè)新的 VLAN 號(hào)或舊的來(lái)進(jìn)
行修改
。
name vlan-name 可選)輸入一個(gè) VLAN 名,如果沒(méi)有配置 VLAN 名,缺省的名字是 VLAN 號(hào)前
面用 0 填滿
的 4 位數(shù),如 VLAN0004 是 VLAN4 的缺省名字
mtu mtu-size (可選) 改變 MTU 大小
例
Switch# configure terminal
Switch(config)# vlan 20
Switch(config-vlan)# name test20
Switch(config-vlan)# end
或
Switch# vlan database
Switch(vlan)# vlan 20 name test20
Switch(vlan)# exit
將端口分配給一個(gè) VLAN
configure terminal 進(jìn)入配置狀態(tài)
interface interface-id 進(jìn)入要分配的端口
switchport mode access 定義二層口
switchport access vlan vlan-id 把端口分配給某一 VLAN
例
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 2
Switch(config-if)# end
Switch#
配置 VLAN trunk
configure terminal 進(jìn)入配置狀態(tài)
interface interface-Id 進(jìn)入端口配置狀態(tài)
switchport trunk encapsulation {isl | dot1q | negotiate}配置 trunk 封裝 ISL 或 802.1Q 或
自動(dòng)協(xié)商
switchport mode {dynamic {auto | desirable} | trunk} 配置二層 trunk 模式。
dynamic auto—自動(dòng)協(xié)商是否成為 trunk
dynamic desirable—把端口設(shè)置為 trunk 如果對(duì)方端口是 trunk, desirable, 配置 Native VLAN
(802.1q)
或自動(dòng)模式,trunk—設(shè)置端口為強(qiáng)制的 trunk 方式,而不理會(huì)對(duì)方端口是否為 trunk
switchport access vlan vlan-id 可選) 指定一個(gè)缺省 VLAN, 如果此端口不再是 trunk
switchport trunk native vlan vlan-id 指定 802.1Q native VLAN 號(hào)
例:
Switch# configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)# interface fastethernet0/4
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk encapsulation dot1q
Switch(config-if)# end
定義 TRUNK 允許的 VLAN
configure terminal 子 進(jìn)入配置狀態(tài)
interface interface-id 進(jìn)入端口配置
switchport mode trunk 配置二層口為 trunk
switchport trunk allowed vlan {add | all | except | remove} vlan-list 可選) 配置 trunk 允
許的 VLAN.使用 add, all, except, remove 關(guān)健字
no switchport trunk allowed vlan 允許所有 VLAN 通過(guò)
例
Switch(config)# interface fastethernet0/1
Switch(config-if)# switchport trunk allowed vlan remove 2
Switch(config-if)# end
配置 Native VLAN(802.1q)
configure terminal 進(jìn)入配置狀態(tài)
interface interface-id 進(jìn)入配置成 802.1qtrunk 的端口
switchport trunk native vlan vlan-Id 配置 native VLAN 號(hào)
no switchport trunk native vlan 端口配置命令回到缺省的狀態(tài)
配置基于端口權(quán)值的負(fù)載均衡
configure terminal 進(jìn)入 Switch 1 配置狀態(tài)
vtp domain domain-name 配置 VTP 域
vtp mode server 將 Switch 1 配置成 VTP server.
show vtp status 驗(yàn)證 VTP 的配置
show vlan 驗(yàn)證 VLAN
configure terminal 進(jìn)入配置狀態(tài)
interface fastethernet 0/1 進(jìn)入 F0/1 端口
switchport trunk encapsulation {isl | dot1q | negotiate}配置 trunk 封裝
switchport mode trunk 配置成 trunk
show interfaces fastethernet0/1 switchport 驗(yàn)證 VLAN 配置
按以上步驟對(duì)想要負(fù)載均衡的接口進(jìn)行配置
在另一個(gè)交換機(jī)上進(jìn)行此配置
show vlan 當(dāng) trunk 已經(jīng)起來(lái),在 switch2 上驗(yàn)證已經(jīng)學(xué)到相的 vlan 配置
configure terminal 在 Switch 1 上進(jìn)入配置狀態(tài)
interface fastethernet0/1 進(jìn)入要配置的端口
spanning-tree vlan 8 port-priority 10 將端口權(quán)值 10 賦與 VLAN 8.
spanning-tree vlan 9 port-priority 10 將端口權(quán)值 10 賦與 VLAN 9.
spanning-tree vlan 10 port-priority 10 將端口權(quán)值 10 賦與 VLAN 10.
interface fastethernet0/2 進(jìn)入 F0/2
spanning-tree vlan 3 port-priority 10 將端口權(quán)值 10 賦與 VLAN 3.
spanning-tree vlan 4 port-priority 10 將端口權(quán)值 10 賦與 VLAN 4
spanning-tree vlan 5 port-priority 10 將端口權(quán)值 10 賦與 VLAN 5
spanning-tree vlan 6 port-priority 10 將端口權(quán)值 10 賦與 VLAN 10
end 退出
show running-config 驗(yàn)證配置
copy running-config startup-config 保存配置
配置 STP 路徑值的負(fù)載均衡
Trunk1 走 VLAN8-10,Trunk2 走 VLAN2-4
configure terminal 進(jìn)入 Switch 1 配置狀態(tài)
interface fastethernet 0/1 進(jìn)入 F0/1
switchport trunk encapsulation {isl | dot1q | negotiate}配置封裝
switchport mode trunk 配置 Trunk,缺省是 ISL 封裝
exit 退回
在 F0/2 口上重復(fù) 2-4 步驟
exit 退回
show running-config 驗(yàn)證配置
show vlan 驗(yàn)證 switch1 已經(jīng)學(xué)到 Vlan
configure terminal 進(jìn)入配置狀態(tài)
interface fastethernet 0/1 進(jìn)入 F0/1
spanning-tree vlan 2 cost 30 設(shè)置 Vlan2 生成樹(shù)路徑值為 30
spanning-tree vlan 3 cost 30 設(shè)置 Vlan3 生成樹(shù)路徑值為 30
spanning-tree vlan 4 cost 30 設(shè)置 Vlan4 生成樹(shù)路徑值為 30
end 退出
在 switch1 的 F0/2 上重復(fù) 9-11 步驟設(shè)置 VLAN8,9,10 生成樹(shù)路徑值為 30
end 退出
show running-config 驗(yàn)證配置
copy running-config startup-config 保存配置
補(bǔ)充:CISCO 命令集——路由選擇協(xié)議及排障
*ip route 命令
Router(config)# ip route <目錄網(wǎng)絡(luò)或子網(wǎng)號(hào)> [子網(wǎng)掩碼] <下一路由器 IP 地址 | 從本地出口
的地址> [管理距離 0~255,默認(rèn)為 1]
(注:靜態(tài)地址配置)
*ip default-network 命令
Router(config)# ip default-network <目標(biāo)網(wǎng)絡(luò)號(hào)>
(注:配合路由協(xié)使用,用其中的一個(gè)動(dòng)態(tài)路由號(hào)作默認(rèn)路由配置)
Router(config)# ip route 0.0.0.0 0.0.0.0 <下一路由器 IP 地址 | 從本地出口的地址>
(注:只有一個(gè)公網(wǎng)地址時(shí),在出口路由器上的配置)
*內(nèi)部路由選擇協(xié)議
*使用 router 和 network 命令
Router(config)# router <路由協(xié)議 rip | igrp | eigrp | ospf | is-is 等> [自主系統(tǒng)號(hào)]
Router(config-router)# network <直接相連的要用此路由協(xié)議的網(wǎng)絡(luò)號(hào)>
Router(config-router)# network <直接相連的要用此路由協(xié)議的網(wǎng)絡(luò)號(hào)>
*路由信息協(xié)議 RIP
Router(config)# router rip
Router(config-router)# network <直接相連的要用 rip 協(xié)議的有類別網(wǎng)絡(luò)號(hào)>
Router# show ip protocols
Router# show ip route
Router# debug ip rip
*內(nèi)部網(wǎng)關(guān)路由協(xié)議 IGRP
Router(config)# router igrp <自主系統(tǒng)號(hào)>
Router(config-router)# network <直接相連的要用 igrp 協(xié)議的有類別網(wǎng)絡(luò)號(hào)>
Router# show ip interface
Router# show ip protocols
Router# show ip route
Router# debug ip rip