技術原理
l? 三層交換機具備網絡層的功能,實現VLAN相互訪問的原理是:利用三層交換機的路由功能,通過識別數據包的IP地址,查找路由表進行選路轉發,三層交換機利用直連路由可以實現不同VLAN之間的相互訪問。三層交換機給接口配置IP地址。采用SVI(交換虛擬接口)的方式實現VLAN間互連。SVI是指為交換機中的VLAN創建虛擬接口,并且配置IP地址。
實驗步驟
新建packet tracer拓撲圖
(1)在二層交換機上配置VLAN2、VLAN3,分別將端口2、端口3劃分給VLAN2、VLAN3。
(2)將二層交換機與三層交換機相連的端口fa 0/1都定義為tag Vlan模式。
(3)在三層交換機上配置VLAN2、VLAN3,此時驗證二層交換機VLAN2、VLAN3下的主機之間不能相互通信。
(4)設置三層交換機VLAN間的通信,創建VLAN2,VLAN3的虛接口,并配置虛接口VLAN2、VLAN3的IP地址。
(5)查看三層交換機路由表。
(6)將二層交換機VLAN2、VLAN3下的主機默認網關分別設置為相應虛擬接口的IP地址。
(7)驗證二層交換機VLAN2,VALN3下的主機之間可以相互通信。
首先在三層交換機上分別設置各VLAN的接口IP地址。三層交換機將vlan做為一種接口對待,就象路由器上的一樣,再在各接入VLAN的計算機上設置與所屬VLAN的網絡地址一致的IP地址,并且把默認網關設置為該VLAN的接口地址。這樣,所有的VLAN也可以互訪了。
實驗設備
Switch_2960 1臺;Swithc_3560 1臺;PC 3臺;直連線如圖1-1
圖1-1
PC1配置
IP地址:? ? ? ? ?? 192.168.1.2
Submark(子網掩碼): ?????? 255.255.255.0
Gateway(網關): ?????? 192.168.1.1
PC2配置
IP地址:??????????? 192.168.2.2
Submark(子網掩碼): ?????? 255.255.255.0
Gateway(網關): ?????? 192.168.2.1???
PC3配置
IP地址:???????????????? 192.168.1.3
Submark(子網掩碼): ?????? 255.255.255.0
Gateway(網關): ?????? 192.168.1.1
打開S2960敲入指令:
Switch>en? ? ? (進入特權模式)
Switch#conf t? ? ?(進入全局配置模式)
Switch(config )#vlan 2
Switch(config-vlan)#exit
Switch(config )#vlan 3
Switch(config-vlan)#exit??????
Switch(config )#int fa 0/2
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config )#int fa 0/3
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
Switch(config )#int fa 0/1
Switch(config-if)#switchport? mode ?trunk
Switch(config-if)#end
Switch#show vlan
打開S3560敲入指令:
Switch>en? ? ? ? (進入特權模式)
Switch#conf t? ? ? (進入全局配置模式)
Switch(config )#vlan 2? (新建虛擬局域網vlan 2)
Switch(config-vlan)#exit? (返回上層配置模式)
Switch(config )#vlan 3? ? ? (新建vlan 3)
Switch(config-vlan)#exit? ?(返回上層配置模式)
Switch(config )#int fa 0/1? ?(進入交換機0模塊第1端口)
Switch(config-if)#switchport trunk encapsulation dot1q? ? ? ? (給這個接口的trunk封裝為802.1Q的幀格式)
Switch(config-if)#switchport mode trunk? (定義這個接口的工作模式為trunk)
Switch(config-if)#exit? ? ? ??(返回上層配置模式)
Switch(config )#int fa 0/2? ?(進入交換機0模塊第2端口)
Switch(config-if)#switchport access vlan 2?? (將當前端口fa0/2劃分到vlan 2中)
Switch(config-if)#exit? ? ? ???(返回上層配置模式)
Switch(config )#interface vlan 2? ? ? ??(進入vlan2 虛擬接口)
Switch(config-if)#ip address 192.168.1.1 255.255.255.0? (配置IP地址為192.168.1.1 子網掩碼為255.255.255.0)
Switch(config-if)#no shutdown? ? ?? (開啟該端口)
Switch(config-if)#exit? ? ? ? ? ??(返回上層配置模式)
Switch(config )#interface vlan 3? ? ???(進入vlan 3虛擬接口)
Switch(config-if)#ip address 192.168.2.1 255.255.255.0? ? ??(配置IP地址為192.168.2.1 子網掩碼為255.255.255.0)
Switch(config-if)#no shutdown? ? ???(開啟該端口)
Switch(config-if)#end? ? ? ? ? ? (退出)
Switch#show ip route? (顯示路由表)
Switch#show vlan? ? ? ?(顯示虛擬局域網vlan配置表)
實驗最終目的????
要求PC1 Ping PC3(IP地址192.168.1.3)有回復
要求PC1 Ping PC2??(IP地址192.168.2.2)有回復? ?
編輯:黃飛
?
評論