trunk配置

實驗  trunk配置

拓撲:

實驗步驟

(1) 配置各路由器相應地址,以備測試

R1(config)#interface  f0/0

R1(config-if)#ip ad 192.168.0.1 255.255.255.0

R1(config-if)#no shut

R2   R3   R4 配置類似與R1

(2) 交換機配置

Switch(config)#hostname sw1

sw1(config)#vlan 2

sw1(config-vlan)#vlan 3

sw1(config-vlan)#exit

sw1(config)#interface  F0/1

sw1(config-if)#switchport mode access

sw1(config-if)#switchport  access  vlan 2

sw1(config-if)#inter f0/2

sw1(config-if)#sw mode ac

sw1(config-if)#sw ac vlan 3

SW2配置:

Switch(config)#hostname  SW2

SW2(config)#vlan 2

SW2(config-vlan)#vlan 3

SW2(config-vlan)#exit

SW2(config)#interface  f0/1

SW2(config-if)#sw mod ac

SW2(config-if)#sw ac vlan 2

SW2(config-if)#interface  f0/2

SW2(config-if)#sw mode  ac

SW2(config-if)#sw ac vlan 3

TRUNK配置

sw1(config)#interface  f0/3

sw1(config-if)#switchport  trunk  encapsulation  dot1q

sw1(config-if)#switchport  mode  trunk

sw2(config)#interface  f0/3

sw2(config-if)#switchport  trunk  encapsulation  dot1q

sw2(config-if)#switchport  mode  trunk //接口配置成trunk

實驗測試;

R1R3    R2R4 都屬於同一VLAN 可以相互通信

R1>en

R1#ping  192.168.0.3    //R1 R3 測試是否通信

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:

!!!!!

r2#ping 192.168.0.4

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.4, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 66/88/94 ms

r2#

SW2#show interfaces  f0/3 switchport

Name: Fa0/3

Switchport: Enabled

Administrative Mode: trunk

Operational Mode: trunk  //當前接口trunk模式

Administrative Trunking Encapsulation: dot1q

Operational Trunking Encapsulation: dot1q

Negotiation of Trunking: On

配置 trunk allowed

sw1(config)#interface  f0/3

sw1(config-if)#switchport  trunk  allowed  vlan 2,200 //f0/3鏈路只允許vlan 2   200數據通過,則R1 R3可以通信,R2  R4不可以通信

R1#ping  192.168.0.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.3, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 65/81/94 ms

R1#

r2#ping 192.168.0.4

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.4, timeout is 2 seconds:

.....

Success rate is 0 percent (0/5)

r2#

配置native VLAN

sw1(config)#interface  f0/3

sw1(config-if)#switchport  trunk  native  vlan 2

sw2(config)#interface  f0/3

sw2(config-if)#switchport  trunk  native  vlan 2

sw1(config)#do show inter tr

Port        Mode         Encapsulation  Status        Native vlan

Fa0/3       on           802.1q         trunking      2

//可以看到trunk鏈路的native vlan 改爲2

調試

2個交換機native  VLAN不一樣時會出現什麼後果。

sw1(config)#interface  f0/3

sw1(config-if)#switchport  trunk  native  vlan 2

sw1(config-if)#

SW2(config)#interface  f0/3

SW2(config-if)#switchport  TRunk  native  vlan 3

SW2(config-if)#

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/3 (2), with SW2 FastEthernet0/3 (3).

R1#ping  192.168.0.4   //測試r1r4是否可以通信

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.4, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 78/87/94 ms

R1#

原因:S1f0/3接口的native  vlan vlan 2,來自vlan 2的數據原封不動的從f0/3接口發送到sw 2上,sw2f0/3接口的native  vlan vlan 3sw2收到一個沒有經過封裝的數據幀後認爲這個幀應該是vlan 3的數據幀,發送r4,從r4返回r1也是類似的


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