Cisco交換機常用配置命令總結

2021-12-21 06:22:58 字數 4263 閱讀 4699

1:配置vlan

理解vlan: 乙個vlan就是乙個交換網,其邏輯上按功能、專案、應用來分而不必考慮

使用者的物理位置。任何交換口都可以屬於某一vlan, ip包、廣播包及組播包均可以傳送或廣播給在此vlan內的終端使用者。每乙個vlan均可看成是乙個邏輯網路,發往另一vlan

的資料報必須由路由器或網橋**,由於vlan被看成是乙個邏輯網路,其具有自己的網橋管理資訊庫(mib) 並可支援自己的生成樹在cisco交換機裡面有兩種配置vlan的方法:

switch# configure terminal

switch(config)# vlan 20

switch(config-vlan)# name test20

switch(config-vlan)# end

也可以在enable狀態下,進行vlan配置:

switch# vlan database

switch(vlan)# vlan 20 name test20

switch(vlan)# exit

刪除vlan

當刪除乙個處於vtp伺服器的交換機上刪除vlan時,則此vlan將在所有相同vtp的交換機上刪除。當在透明模式下刪除時,只在當前交換機上刪除,用vlan database 進入vlan

配置狀態,用no vlan vlan-id來刪除。

switch# vlan database

switch(vlan)# no vlan 20

switch(vlan)# exit

將埠分配給乙個vlan

switch# configure terminal

switch(config)# inte***ce fastethernet0/1

switch(config-if)# switchport mode access

switch(config-if)# switchport access vlan 2

switch(config-if)# end

2:配置vlan trunks

所謂的trunk是用來在不同的交換機之間進行連線,以保證在跨越多個交換機上建立的同乙個vlan的成員能夠相互通訊,如果是不同臺的交換機上相同id的vlan要相互通訊,那麼可以通過共享的trunk埠就可以實現,如果是不同臺不同id的vlan它們之間要相互通訊,需要通過第三方的路由來實現

.switch# configure terminal

switch(config)# inte***ce fastetherne2/4

switch(config-if)# switchport mode trunk

switch(config-if)# switchport trunk encapsulation dot1q

switch(config-if)# end

定義trunk允許的vlan預設情況下trunk允許所有的vlan通過可以使用switchport trunk allowed vlan remove vlan-list來去掉某一vlan

switch(config)# inte***ce fastethernet2/4

switch(config-if)# switchport trunk allowed vlan remove 2

switch(config-if)# end

3:使用stp實現負載均衡

負載均衡可以使用流量分流到其它平行的trunks上去. 交換機為了避免環路,stp通常是阻斷所有端**換機之間只留一條鏈路,使用負載均衡後, 可以把不同vlan的流量分配到不同的trunk上。可以通過配置stp埠權值stp路徑值來實現負載均衡,如果使用stp埠權值來配置那麼二條負載均衡的trunk必須聯同一交換機上;使用路徑值則即可以聯相同的交換機與可以聯不同的交換機。

使用stp埠權值的負載均衡當同一臺交換機的二個口形成環路時,stp埠權值用來決定那個口是enable的,那個口是阻斷的。可以通過配置埠權值來決定二對trunk各走那些vlan, 有較高權值的埠(數字較小的)vlan, 將處於**狀態,同乙個vlan在另乙個trunk有較低的權值(數字較大)則將處在阻斷狀態,即同一vlan只在乙個trunk上傳送接受。基於埠權值的負載均衡,trunk1將傳送和接收vlan8

-10的資料,trunk2將傳送和接收vlan3-5的資料

inte***ce fastethernet0/1 (進入trunk1口)

spanning-tree vlan 8 port-priority 10

spanning-tree vlan 9 port-priority 10

spanning-tree vlan 10 port-priority 10

inte***ce fastethernet0/2 (進入trunk2口)

spanning-tree vlan 3 port-priority 10

spanning-tree vlan 4 port-priority 10

spanning-tree vlan 5 port-priority 10

也可以通過配置配置stp路徑值來實現負載均衡,trunk1走vlan8-10,trunk2

走vlan2-4

inte***ce fastethernet 0/1 (進入trunk1口)

spanning-tree vlan 8 cost 30

spanning-tree vlan 9 cost 30

spanning-tree vlan 10 cost 30

inte***ce fastethernet 0/2 (進入trunk2口)

spanning-tree vlan 2 cost 30

spanning-tree vlan 3 cost 30

spanning-tree vlan 4 cost 30

4:配置etherchannel etherchannel特性在switch到switch、switch到router之間提供冗餘的、

高速的連線方式,簡單說就是將兩個裝置間多條fe或ge物理鏈路捆在一起組成一條裝置間邏輯鏈路,從而達到增加頻寬,提供冗餘的目的,每個以太通道具有乙個port-channel埠號,

要**乙個以太通道時,會產生乙個邏輯port-channel埠,邏輯埠下的配置可影響與之**的物理埠,但物理埠下的配置不能影響邏輯埠的配置

switch# configure terminal

switch(config)# inte***ce port-channel 1

switch(config-if)# ip address 172.16.30.10 255.255.255.0

switch(config-if)# end

三層物理埠配置

switch# configure terminal

switch(config)# inte***ce range fastethernet 3/4 - 5

switch(config-if)# no switchport

switch(config-if)# no ip address

switch(config-if)# channel-group 1 mode desirable

switch(config-if)# end

二層以太通道配置

switch# configure terminal

switch(config)# inte***ce range fastethernet 2/6 - 7

switch(config-if-range)# channel-group 2 mode desirable

switch(config-if-range)# end

5:配置以太通道負載均衡

負載均衡關鍵字表示如下:

src-mac—源mac位址

dst-mac—目標mac位址

src-dst-mac—源和目標mac位址

src-ip—源ip位址

dst-ip—目標ip位址

src-dst-ip—源和目標ip位址 (預設)

src-port—源第四層埠

dst-port—目標第四層埠

src-dst-port—源和目標第四層埠

switch(config)# port-channel load-balance src-dst-ip

switch(config)# end

this example shows how to verify the configuration:

switch# show etherchannel load-balance source xor destination ip address

switch#

CISCO交換機配置命令大全

1.在基於ios的交換機上設定主機名 系統名 switch config hostname hostname 在基於cli的交換機上設定主機名 系統名 switch enable set system name name string 2.在基於ios的交換機上設定登入口令 switch confi...

CISCO交換機配置命令大全總結

全新的cisco配置命令 配置使能密碼enable secret ciscolab 以cicsolab 為例 switch enable switch c onfigure terminal switch conf hostname aptch2950 aptech2950 conf enable ...

Cisco交換機配置DHCP例項

cisco 3550 48交換機配置dhcp例項 2009 12 11 11 43作者 tsingfu 51cto 一 catalyst 3550 48配置成dhcp中繼 一次公司開會,需要臨時組建乙個區域網進行交流,要求與會者自帶電腦。計畫使用一台tp link tl wr541g無線寬頻路由器進...