不同VLan的連通

一、實驗說明:按照網絡拓撲圖連接並設置好PC機的IP地址,要求PC1、PC2屬於VLAN 12,PC3、PC4屬於VLAN 34,現通過實驗實現VLan 12與VLan 34間的互通,PC1~PC4兩兩任意互通。

附網絡拓撲圖:


wKiom1njmBiBrhNdAABRTRueQhA897.jpg-wh_50

交換機一上的配置:

Switch>enable

Switch#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname SW1

SW1(config)#no ip domain lookup

SW1(config)#line console 0

SW1(config-line)#exec-timeout 0 0

SW1(config-line)#exit

SW1(config)#vlan 12

SW1(config-vlan)#exit

SW1(config)#vlan 34

SW1(config-vlan)#exit

SW1(config)#interface f0/1

SW1(config-if)#no shutdown

SW1(config-if)#switchport mode access

SW1(config-if)#switchport access vlan 12

SW1(config-if)#exit

SW1(config)#interface f0/4

SW1(config-if)#no shutdown

SW1(config-if)#switchport mode access

SW1(config-if)#switchport access vlan 34

SW1(config-if)#exit

SW1(config)#interface f0/24

SW1(config-if)#no shutdown

SW1(config-if)#switchport mode trunk


%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up


SW1(config-if)#exit



交換機二上的配置:

Switch>enable

Switch#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname SW2

SW2(config)#line console 0

SW2(config-line)#exec-timeout 0 0

SW2(config-line)#exit

SW2(config)#vlan 12

SW2(config-vlan)#exit

SW2(config)#vlan 34

SW2(config-vlan)#exit

SW2(config)#interface f0/2

SW2(config-if)#no shutdown

SW2(config-if)#switchport mode access

SW2(config-if)#switchport access vlan 12

SW2(config-if)#exit

SW2(config)#interface f0/3

SW2(config-if)#no shutdown

SW2(config-if)#switchport mode access

SW2(config-if)#switchport access vlan 34

SW2(config-if)#exit

SW2(config)#interface f0/24

SW2(config-if)#no shutdown

SW2(config-if)#switchport mode trunk

SW2(config-if)#exit


     @以下四行配置多層交換與級聯交換機的互聯鏈路爲trunk

SW2(config)#interface f0/23

SW2(config-if)#no shutdown

SW2(config-if)#switchport mode trunk

SW2(config-if)#end

SW2(config-if)#



多層交換機的配置:

Switch>enable

Switch#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#hostname MLSW-VLan-Gateway

MLSW-VLan-Gateway(config)#ip routing     //開啓多層交換機的路由功能,很重要!

    @使用的是邏輯接口,爲每個VLAN配置一個網關IP

MLSW-VLan-Gateway(config)#vlan 12

MLSW-VLan-Gateway(config-vlan)#exit

MLSW-VLan-Gateway(config)#vlan 34

MLSW-VLan-Gateway(config-vlan)#interface vlan 12

MLSW-VLan-Gateway(config-if)#no shutdown

MLSW-VLan-Gateway(config-if)#ip address 192.168.12.254 255.255.255.0

MLSW-VLan-Gateway(config-if)#exit

MLSW-VLan-Gateway(config)#interface vlan 34

MLSW-VLan-Gateway(config-if)#no shutdown

MLSW-VLan-Gateway(config-if)#ip address 192.168.34.254 255.255.255.0

MLSW-VLan-Gateway(config-if)#exit

     @以下四行配置多層交換與級聯交換機的互聯鏈路爲trunk

MLSW-VLan-Gateway(config)#interface f0/23

MLSW-VLan-Gateway(config-if)#no shutdown

MLSW-VLan-Gateway(config-if)#switchport trunk encapsulation dot1q  //必須手動設置封裝協議

MLSW-VLan-Gateway(config-if)#switchport mode trunk

MLSW-VLan-Gateway(config-if)#end



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章