糯米文學吧

位置:首頁 > IT認證 > 思科認證

思科三層交換機配置命令大全

Cisco的名字取自San Francisco(舊金山),那裏有座聞名於世界的金門大橋。可以説,依靠自身的技術和對網絡經濟模式的深刻理解,思科成為了網絡應用的成功實踐者之一。為幫助同學們更好去學習思科交換機配置,yjbys小編為大家帶來最新配置命令如下:

思科三層交換機配置命令大全

  配置一組二層端口

configure terminal 進入配置狀態

nterface range {port-range} 進入組配置狀態

  配置三層端口

configure terminal 進入配置狀態

interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-channel port-channel-number} 進入端口配置狀態

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

Switch(config-if)# no shutdown

  配置VLAN

configure terminal 進入配置狀態

vlan vlan-id 輸入一個VLAN號, 然後進入vlan配態,可以輸入一個新的VLAN號或舊的來進行修改。

name vlan-name 可選)輸入一個VLAN名,如果沒有配置VLAN名,缺省的名字是VLAN號前面用0填滿的4位數,如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

  將端口分配給一個VLAN

configure terminal 進入配置狀態

interface interface-id 進入要分配的端口

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 進入配置狀態

interface interface-Id 進入端口配置狀態

switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封裝ISL 或 802.1Q 或自動協商

switchport mode {dynamic {auto | desirable} | trunk} 配置二層trunk模式。

dynamic auto—自動協商是否成為trunk

dynamic desirable—把端口設置為trunk如果對方端口是trunk, desirable, 配置Native VLAN(802.1q)

或自動模式,trunk—設置端口為強制的trunk方式,而不理會對方端口是否為trunk

switchport access vlan vlan-id 可選) 指定一個缺省VLAN, 如果此端口不再是trunk

switchport trunk native vlan vlan-id 指定802.1Q native VLAN號

例:

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子 進入配置狀態

interface interface-id 進入端口配置

switchport mode trunk 配置二層口為trunk

switchport trunk allowed vlan {add | all | except | remove} vlan-list可選) 配置trunk允許的VLAN.使用add, all, except, remove關健字

no switchport trunk allowed vlan 允許所有VLAN通過

Switch(config)# interface fastethernet0/1

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

Switch(config-if)# end

  配置Native VLAN(802.1q)

configure terminal 進入配置狀態

interface interface-id 進入配置成802.1qtrunk的端口

switchport trunk native vlan vlan-Id 配置native VLAN號

no switchport trunk native vlan 端口配置命令回到缺省的狀態

配置基於端口權值的負載均衡

configure terminal 進入Switch 1配置狀態

vtp domain domain-name 配置VTP域

vtp mode server 將Switch 1配置成VTP server.

show vtp status 驗證VTP的配置

  show vlan 驗證VLAN

configure terminal 進入配置狀態

interface fastethernet 0/1 進入F0/1端口

switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封裝

switchport mode trunk 配置成trunk

show interfaces fastethernet0/1 switchport 驗證VLAN配置

按以上步驟對想要負載均衡的接口進行配置

在另一個交換機上進行此配置