思科交換機命令大全
云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 1 -思科交換機常用命令大全1.1 用戶模式與特權(quán)模式用戶模式:可以使用一些基本的查詢命令特權(quán)模式:可以對交換機進行相關(guān)的配置進入特權(quán)模式命令:Swit
云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 1 -
思科交換機常用命令大全
1.1 用戶模式與特權(quán)模式
用戶模式:可以使用一些基本的查詢命令
特權(quán)模式:可以對交換機進行相關(guān)的配置
進入特權(quán)模式命令:Switch>enable
退出特權(quán)模式命令:Switch#exit
啟用命令查詢:?
時間設(shè)置:Switch#clock set 時間(自選參數(shù),參數(shù)必須符合交換機要求) 顯示信息命令:Switch#show 可選參數(shù)
注意:可以用TAB 鍵補齊命令,自選參數(shù)為用戶自定義參數(shù),可選參數(shù)為交換機設(shè)定參數(shù)
查看交換機配置: Switch#show running-config
保存交換機配置:Switch#copy running-config startup-config
Switch#wr
查看端口信息:Switch#show interface
查看MAC 地址表:Switch#show mac-address-table
查看交換機CPU 的狀態(tài)信息:Switch#show processes
1.2 全局配置模式
進入全局配置模式:Switch#configure terminal
,云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 2 - 主機名修改:Switch(config)#hostname 主機名(自選參數(shù))
特權(quán)模式進入密碼: Switch(config)#enable secret 密碼(自選參數(shù)) 取消特權(quán)模式密碼:Switch(config)#no enable secret
取消主機名設(shè)置: Switch(config)#no hostname
退出配置模式: Switch(config)#exit
需要特別注意的是在配置模式中無法使用show 命令,如果要使用
的話show 前必須加do 和空格,例如:do show *
指定根交換機命令:Switch(config)#spanning-tree vlan 自選參數(shù)(VLAN 號) root primary
例如: Switch(config)#spanning-tree vlan 1 root primary
需要注意的是:設(shè)置根交換機是基于VLAN 的
關(guān)閉生成樹協(xié)議命令:Switch(config)#no spanning-tree vlan 自選參數(shù)(VLAN 號)
例如: Switch(config)#no spanning-tree vlan 1
1.3 接口配置模式
進入接口配置模式:Switch(config)#interface 端口名稱(可選參數(shù)) 啟用端口:Switch(config-if)#no shutdown
停用端口:Switch(config-if)#shutdown
進入同種類型多端口配置:Switch(config)# interface range fastethernet 0/1-5
進入不同類型多端口配置:Switch(config)#interface range fastethernet 0/1-5,gigabitethernet 0/1-2
,云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 3 - 退出接口配置模式:Switch(config-if)#exit
1.4 二層端口的配置
端口速率: Switch(config-if)#speed 可選參數(shù) 雙工模式: Switch(config-if)#duplex 可選參數(shù)
禁用鏈路協(xié)商:Switch(config-if)#no negotiation auto 啟用鏈路協(xié)商:Switch(config-if)#negotiation auto
1.5 VLAN的配置
新建VLAN :Switch(config)#vlan 自選參數(shù)(VLAN 號)
Switch(config-vlan)#name自選參數(shù)(VLAN 名)
例如:Switch(config)#vlan 1
Switch(config-vlan)#name lab1
Switch(config-vlan)#exit
刪除VLAN : Switch#vlan database
Switch(vlan)#no vlan 自選參數(shù)(vlan 號) 例如:Switch#vlan database
Switch(vlan)#no vlan 2
將一個接口加入VLAN :
Switch(config)#interface 可選參數(shù)(接口號)
,云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 4 - Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 自選參數(shù)(VLAN 號) Switch(config-if)#no shutdown
Switch(config-if)#exit
例如:Switch(config)#interface f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 1
Switch(config-if)#no shutdown
Switch(config-if)#exit
將一個接口退出VLAN :
Switch(config)#interface 可選參數(shù)(接口號)
Switch(config-if)#no switchport access vlan 自選參數(shù)(VLAN 號) 例如:Switch(config)#interface f0/1
Switch(config-if)#no switchport access vlan 2
修改一個接口為端口匯聚模式
Switch(config)#interface 可選參數(shù)(接口號)
Switch(config-if)#switchport mode trunk
VLAN 的驗證命令:
Switch#show vlan 顯示VLAN 列表
Switch#show interface switchport 查看具體接口的VLAN 成員資格信息
,云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 5 -
1.6 VTP的配置
VTP Domain Name(VTP 域名)
Switch#configure terminal
Switch(config)#vtp domain 自選參數(shù)
例如: Switch(config)#vtp domain Lab_Network
VTP mode(VTP 模式)
Switch(config)#vtp mode 可選參數(shù)(Server|Client| Transparent) 例如: Switch(config)#vtp mode Server
VTP Pruning(VTP 修剪)
Switch(config)#vtp pruning
注意:有的交換機不支持VTP 修剪命令
查看VTP 的配置命令:
Switch#show vtp status
顯示交換機運行的VTP 模式,配置修訂號和交換機所屬的VTP 域 Switch#show vtp counters
顯示VTP 消息相關(guān)的統(tǒng)計數(shù)據(jù)
1.7 遠(yuǎn)程登錄交換機設(shè)置
配置管理VLAN :
Switch(conf)#interface vlan 1
Switch(config-if)#ip address x.x.x.x 255.255.255.0
,云南愛因森軟件職業(yè)學(xué)院網(wǎng)絡(luò)技術(shù)專業(yè)實訓(xùn)報告 - 6 - Switch(config-if)#no shutdown
注意:IP 地址必須與遠(yuǎn)程連接交換機的PC 機地址在同一網(wǎng)段 在交換機上指定默認(rèn)網(wǎng)關(guān):
Switch(config)#ip default-gateway x.x.x.x
注意:指定的默認(rèn)網(wǎng)關(guān)僅當(dāng)前交換機有效。
將交換機連接PC 機的端口加入VLAN 1
Switch(config)#interface 端口號(可選參數(shù))
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 1
Switch(config-if)#no shutdown
配置交換機的遠(yuǎn)程登錄
Switch(config)#line vty 0 4
Switch(config-line)#password 自選參數(shù)
Switch(config-line)#login
Switch(config)#enable secret 自選參數(shù)