vlan trunk配置

vlan trunk配置

Trunk:中繼幹道

作用:一條鏈路能承載多個vlan的流量,並對不同vlan的流量進行不同標記

           trunk能夠使vlan跨越交換機

PT配置



配置vlan:兩臺交換機同樣的命令

Switch(config)#vlan 10 配置vlan10

Switch(config)#vlan 20 配置vlan20

Switch(config)#show vlan 查看vlan

Switch(config)#interface f0/1

Switch(config-if)#switchport access vlan 10

Switch(config)#interface f0/2

Switch(config-if)#switchport access vlan 20


配置trunk:只做其中的一臺就行

Switch(config)#interface fa0/3

//Switch(config-if)#switchport trunk encapsulation dot1q //定義封裝模式(默認802.1Q)三層交換,可以不寫

Switch(config-if)#switchport mode trunk 

Switch#Show interface trunk 查看trunk



DTP:交換機數量比較多的時候,手動配置trunk比較麻煩,所以開發了DTP協議,只要交換機之間連接起來,開機之後交換機會發送trunk的協商包進行協商,從而動態的創建trunk


在cisco的交換機上,DTP(動態trunk協議)是默認開啓的,所以做了一臺交換機爲trunk之後,另一臺的相連的自動協商成爲trunk模式

關閉協商的命令: 

Interface fx/x 

Switchport mode trunk //強制指定爲trunk 

Switchport nonegotiation //關閉DTP協商


進入接口配置只允許哪些vlan流量可以通過trunk

Interfacefx/x

Switchporttrunkallowedvlan x,x


GNS3配置


兩臺交換機的配置

R2#enable  
R2#configure terminal 
R2(config)#no ip routing 
R2#vlan database //進入vlan數據庫
R2(vlan)#vlan 10
R2(vlan)#vlan 20
R2(config)#interface f0/0
R2(config-if)#switchport access vlan 10
R2(config-if)#no shutdown 
R2(config)#interface f0/1
R2(config-if)#switchport access vlan 20
R2(config-if)#no shutdown 
R2#show vlan-switch 查看vlan信息
R2(config)#interface f0/2
R2(config-if)#switchport mode trunk 配置模式爲vlan
R2#show interfaces trunk  查看接口的trunk信息


4臺pc的配置

R4#enable 
R4#configure terminal 
R4(config)#no ip routing 
R4(config)#interface fastEthernet 0/0
R4(config-if)#ip addr
R4(config-if)#ip address 192.168.1.2 255.255.255.0
R4(config-if)#no shutdown 
R4(config-if)#exit



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