3.9 實現(xiàn)交換機Trunk功能
3.9.1 實驗目的
- 通過VLAN Trunk技術跨交換機的VLAN配置
3.9.2 背景描述
假設某公司有多個部門。每個部門的個人計算機系統(tǒng)分散在兩臺交換機上,公司要求,部門內的計算機能夠相互通信,部門間不能進行互訪,現(xiàn)能過跨交換機進行配置實現(xiàn)這一目標。為了避免低效率的連接方式,我們可以讓交換機間互聯(lián)的網線集中到一根上進行,這就是Trunk技術。
3.9.3 實驗設備
- 兩臺RG S2126G交換機
- 五臺PC機,其中一臺可以打開管理端網頁,進行設備配置
- 直通雙絞線若干,交叉雙絞線若干
3.9.4 實驗拓撲圖
實驗拓撲如圖1-7所示:
圖1-7 Trunk配置
3.9.5 實驗步驟
為了清晰起見,建議刪除交換機上所有配置并且重新啟動交換機。
- 配置VLAN Trunk端口
分別在服務器和客戶端進行中繼端口設置
S2126_1(config)#interface fastEthernet 0/24
S2126_1(config-if)#switchport mode trunk (f0/24端口鏈路模式設置為Trunk)
S2126_1(config-if)#switchport trunk ?
allowed Set allowed VLAN characteristics when interface is in
trunking mode
native Set trunking native characteristics when interface is
in trunking mode
S2126_1(config-if)#switchport trunk allowed ?
vlan Set allowed VLANs when interface is
in trunking mode
S2126_1(config-if)#switchport trunk allowed vlan ?
add Add VLANs to the current list
all All VLANs
except All VLANs except the following
remove Remove VLANs from the current list
S2126_1(config-if)#switchport trunk allowed vlan all (允許所有VLAN信息通過此Trunk鏈路口)
S2126_1(config-if)#Switch(config-if)#exit
S2126_1(config)#exit
在Switch 2中做同樣的配置。
- 創(chuàng)建VLAN
VLAN信息可以在服務器模式或透明模式交換機上創(chuàng)建。
交換機1:
S2126_1(config)#vlan 2
S2126_1(config-vlan)#name Workgroup2 (為VLAN 2命名:Workgroup2)
S2126_1(config-vlan)#exit
S2126_1(config)#vlan 3 (創(chuàng)建VLAN 3)
S2126_1(config-vlan)#name Workgroup3 (為VLAN 3命名:Workgroup3)
S2126_1(config-vlan)#exit
S2126_1(config)# exit
交換機2:
Switch #conf t
Switch(config)#hostname S2126_2 (交換機重命名為S2126_2)
S2126_2(config)#vlan 2 (創(chuàng)建VLAN 2)
S2126_2(config-vlan)#name Workgroup2 (為VLAN 2命名:Workgroup2)
S2126_2(config-vlan)#exit
S2126_2(config)#vlan 3 (創(chuàng)建VLAN 3)
S2126_2(config-vlan)#name Workgroup3 (為VLAN 3命名:Workgroup3)
S2126_2(config-vlan)#exit
S2126_2(config)#
- 在交換機1和交換機2中分別將端口加入VLAN中
S2126_1(config)#interface range fastEthernet 0/1 - 8
S2126_1(config-if-range)#switchport access vlan 2
S2126_1(config-if-range)#no shut
S2126_1(config-if-range)#exit
S2126_1(config)#interface range fastEthernet 0/9 - 16
S2126_1(config-if-range)#switchporta access vlan 3
S2126_1(config-if-range)#no shut
S2126_1(config-if-range)#exit
S2126_1(config)#exit
S2126_1#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/17,Fa0/18,Fa0/19
Fa0/20,Fa0/21,Fa0/22
Fa0/23,Fa0/24
2 Workgroup2 active Fa0/1 ,Fa0/2 ,Fa0/3
Fa0/4 ,Fa0/5 ,Fa0/6
Fa0/7 ,Fa0/8 ,Fa0/24
3 Workgroup3 active Fa0/9 ,Fa0/10,Fa0/11
Fa0/12,Fa0/13,Fa0/14
Fa0/15,Fa0/16,Fa0/24
交換機2中做一樣的配置。
接下來將PC1用直通雙絞線連接到S2126_1交換機C2連接到VLAN 3中,PC3用直通雙絞線連接到S2126_2交換機C4連接到VLAN 3中。測試VLAN間的內部通信。
實驗結果:
- PC1和PC3相互PING。(截圖)
- PC1和PC2相互PING。(截圖)