程瑩
摘要:VLAN(Virtual Local AreaNetwork)即虛擬局域網,是一種通過將局域網內的設備邏輯地而不是物理地劃分成一個個網段從而實現虛擬工作組的新興技術,VLAN技術較傳統LAN技術前進了一大步,讓我們在遼闊的信息領域中擁有屬于自己的空間。
關鍵詞:VLAN;跨交換機
VLAN是英文Virtual Local Area Network的縮寫,即虛擬局域網。VLAN是對連接到的第二層交換機端口的網絡用戶的邏輯分段,不受網絡用戶的物理位置限制而根據用戶需求進行網絡分段。一個VLAN可以在一個交換機或者跨交換機實現。VLAN可以根據網絡用戶的位置、作用、部門或者根據網絡用戶所使用的應用程序和協議來進行分組。基于交換機的虛擬局域網能夠為局域網解決沖突域、廣播域、帶寬問題。一方面,VLAN建立在局域網交換機的基礎之上;另一方面,VLAN是局域交換網的靈魂。這是因為通過 VLAN用戶能方便地在網絡中移動和快捷地組建寬帶網絡,而無需改變任何硬件和通信線路。VLAN充分體現了現代網絡技術的重要特征:高速、靈活、管理簡便和擴展容易。VLAN與普通局域網從原理上講沒有什么不同,但從用戶使用和網絡管理的角度來看,VLAN與普通局域網最基本的差異體現在:VLAN并不局限于某一網絡或物理范圍,VLAN中的用戶可以位于一個園區的任意位置,甚至位于不同的國家。
下面,我們通過一個實際案例來實現運用三層交換機實現不同VLAN間相互通信,
步驟1.在交換機SwitchA上創建vlan 10 ,并將0/5端口劃分到vlan 10 中.
SwitchA>enable
SwitchA#configure terminal
SwitchA(config)#vlan 10
SwitchA(config-vlan)#name sales
SwitchA(config-vlan)#exit
SwitchA(config)#interface fastEthernet 0/5
SwitchA(config-if)#switchport access vlan 10
SwitchA(config-if)#exit
SwitchA(config)#vlan 20
SwitchA(config-vlan)#name technical
SwitchA(config-vlan)#exit
SwitchA(config)#interface vlan 20
SwitchA(config-if)#exit
SwitchA(config)#interface fastEthernet 0/15
SwitchA(config-if)#switchport access vlan 20
SwitchA(config-if)#exit
步驟2.把交換機SwichA和SwichB相連的端口定義為tag vlan模式
SwitchA(config)#interface fastEthernet 0/24
SwitchA(config-if)#switchport mode trunk
!將F0/24端口定義為tag vlan模式
驗證測試:驗證F0/24端口已被設為tag vlan模式
SwitchA#show interfaces fastEthernet 0/24 switchport
I……
步驟3.在交換機SwichB上創建vlan 10,并將0/5端口劃分到vlan 10中.
SwichB(config)#vlan 10
SwichB(config-vlan)#name salse
SwichB(config-vlan)#exit
SwichB(config)#interface fastEthernet 0/5
SwichB(config-if)#switchport access vlan 10
步驟4.把交換機SwichB和SwichA相連的端口定義為tag vlan模式
SwichB(config)#interface fastEthernet 0/24
SwichB(config-if)#switchport mode trunk
驗證測試:驗證F0/24端口已被設置為tag vlan模式
SwichB#show interfaces fastEthernet 0/24 switchport
步驟5.驗證PC1與PC3能相互通信,但PC2和PC3不能相互通信。
C:Documents and SettingsAdministrator>ping 192.168.10.30
!在PC1的命令行方式下能ping通PC3
Pinging 192.168.10.30 with 32 bytes of data:
Reply from 192.168.10.30: bytes=32 time<1ms TTL=128
Reply from 192.168.10.30: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.10.30:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:Documents and SettingsAdministrator>ping 192.168.10.30
!在PC2的命令行方式下驗證不能ping通PC3
Pinging 192.168.10.30 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.10.30:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
步驟6.設置三層交換機VLAN間通信
SwitchA(config)#interface vlan 10 !創建虛擬接口vlan 10
SwitchA(config-if)#ip address 192.168.10.254 255.255.255.0
!配置虛擬接口vlan 10 的地址為192.168.10.254
SwitchA(config-if)#no shutdown !開啟端口
SwitchA(config-if)#exit
SwitchA(config)#interface vlan 20 !創建虛擬接口vlan 20
SwitchA(config-if)#ip address 192.168.20.254 255.255.255.0
!配置虛擬接口的地址為192.168.20.254
SwitchA(config-if)#no shutdown!開啟端口
SwitchA(config-if)#exit
驗證測試:查看S3550路由器的狀態
SwitchA#show ip interface!查看IP接口的狀態
Interface: VL10
Description: Vlan 10
OperStatus : up
ManagementStatus : Enabled
Primary Internet address: 192.168.10.254/24
Broadcast address: 255.255.255.255
PhysAddress: 00d0.f8b8.289c
Interface: VL20
Description: Vlan 20
OperStatus : up
ManagementStatus : Enabled
Primary Internet address: 192.168.20.254/24
Broadcast address: 255.255.255.255
PhysAddress: 00d0.f8b8.289b
步驟7.將PC1和PC3的網關設置為192.168.10.254,將PC2的默認網關設置成192.168.20.254
測試結果:不同vlan間的主機可以相互ping通
參考配置
SwichA#show running-config !顯示交換機SwichA的全部配置
I……
SwichB#show running-config !顯示交換機SwichB的全部配置
………
參考文獻
[1] 魏大新. 《cisco網絡技術教程》電子工業出版社, 2007年4月
[2] 譚浩強.《cisco路由實用技術》中國鐵道出版社,2006年5月