<b>trunk</b>
<b>一、回顧(trunk</b><b>應用場景及可用地方)</b>
1、無trunk 2950-------1900 一個vlan一條鍊路
2、交換機互連 通過打标記去承載多個vlan的資料
3、單臂路由 switch------router 子接口實作vlan間通信
4、switch---server 伺服器網卡支援trunk
<b>二、trunk</b>
1、作用(使用一根實體鍊路傳送多個vlan的資料流量)
2、辨別方式:802.1Q/isl
3、辨別比較:
802.1Q isl
IEEE标準 思科私有
封裝 打tag
30bytes 4bytes
native vlan
<b>三、trunk</b><b>封裝詳解</b>
1、isl inter-switch link protocol
1500+18+30=1548
DA40+TYPE4+USER4+SA48+LEN16+SNAP/LLC24+HSA24+VLAN ID15+BPDU1+INDEX16+保留16+被封裝的幀+CRC32
支援1024個VLAN
擴充VLAN不能經過ISL封裝的trunk
DA:目标位址 0x 01(3)-00-0c-00-00
TYPE:被封裝的幀類型
0000--ethernet 0001--token ring 0010--fddi 0011--atm
USER:0000--token ring
SA:源位址,發送switch的MAC位址
LEN:isl頭加資料,不包含以太網幀頭
SNAP:AAAA--03
HSA:isl SA的高位位元組
vlan ID: 标示VLAN,隻用其中10bit
BPDU: 1表示STP isl vtp cdp資訊
index:索引,源交換機輸出port.
2、IEEE 802.1Q
DA+SA+TAG+type+data+fcs
tpid16+802.1p3+cfi1+vlan id12
TPID:(tag protocol id)告知接收方面緊跟的是802.1Q的包,0x8100
priority:802.1p優先級8個級别(0-7),預設為0
CFI:格式辨別,0以太網,1 FDDI token ring
vlan id:支援4096 個vlan
3、802.1Q native vlan
a、在一個交換網絡中,幀有兩種格式:标記幀和未标記幀.
b、Native VLAN是TRUNK上才有的概念.主要的目的是不丢棄非标記幀.接收方交換機把所有接收到的未标記的資料包轉發到NATIVE VLAN中,而不是丢棄.預設是VLAN1.
c、要求TRUNK兩側的NATIVE VLAN必須相同,如果不比對,鍊路不能正常工作.因為,如果NATIVE不一緻,STP會讓端口處于PVID不一緻狀态,在鍊路上不會轉發流量.
d、屬于NATIVE VLAN的幀在802.1Q TRUNK上傳輸的時候不标記。
e、CDP版本2在CISCO交換機之間傳送NATIVE VLAN的資訊,如果不比對,會在控制台上看到CDP出錯消息。
f、交換機上的每個端口都有一個稱為PVID(端口VLAN ID)的參數.根據端口的設定,交換機為每個802.1Q端口配置設定一個PVID值.所有交換機都把未标記的幀配置設定到PVID參數所指定的VLAN.
4、vlan 類型
Vlan range
Use
0,4095
保留
1
思科預設
2-1001
以太網VLAN
1002-1005
FDDI、Token Ring
1006-4094
四、配置 (示範)
1、封裝
Sw4(config-if)#switchport trunk encapsulation ?
dot1q Interface uses only 802.1q trunking encapsulation when trunking
isl Interface uses only ISL trunking encapsulation when trunking
negotiate Device will negotiate trunking encapsulation with peer on
interface
n-isl n-802.1q negotiate isl 802.1q Trunking other
2、檢視
Show int trunk show int f0/1 trunk show int f0/1 switchport show run int f0/1
3、協商(DTP dynamic trunk protocol)
DTP是思科私有協定動态協商成trunk.DTP總是在native vlan 中傳送,每隔30秒發送一次,DTP包中包含VTP域名,trunk封裝模式。VTP域名不同,不能自動形成trunk.
Off 不可能成為trunk (switchport mode access)
on 可以和on、 主動、被動成為trunk (switchport mode trunk)
主動可以和on、 主動、被動成為trunk (switchport mode dynamic desirable)
被動可以和on、 主動成為trunk (switchport mode dynamic auto)
不協商(switchport nonegotiate)可以與trunk、access結合使用
4、改native vlan
Sw4(config-if)#switchport trunk ?
allowed Set allowed VLAN characteristics when interface is in trunking
mode
encapsulation Set trunking encapsulation when interface is in trunking mode
native Set trunking native characteristics when interface is in
trunking mode
pruning Set pruning VLAN characteristics when interface is in trunking
mode
Sw4(config-if)# switchport trunk native vlan n
5、接口allowed vlan
switchport trunk allowed vlan all/add/except/remove
所有/追加/除…之外/移除