Cisco Vlan Trunk

ps:以下設定以2950switch為主

設定trunk 封裝方法
(config)#int < interface>
(config-if)switchport trunk encapsulation < type>
< type>有ISL,dot1q,negotiate 
 ISL:用CISCO ISL將frame整個封裝 
 dot1q:用802.1q在frame上加tag(除了native vlan is sent normally and is not tagged)
 negotiate(the default):自動從ISL或dot1q選一個用,若都支援則使用ISL 
ps:
可選type依各機器可能不同,3550switch有isl,dot1q,negotiate,2912有isl,dot1q,2950只有dot1q,1900只有isl
ps:
A Catalyst switch will report giants if one side is configured for ISL/802.1q while the other side is not
ps:
trunk時要注意兩邊介面speed/duplex要一致

encapsulation dot1q
(config-if)#encapsulation dot1q < vlan-id>
Use the encapsulation dot1q subinterface command to enable IEEE 802.1Q encapsulation of traffic on a specified subinterface in virtual LANs
< vlan-id> The allowed range is 1-1000
ex:
encapsulates VLAN traffic for VLAN 100 
(config)#interface fastethernet 4/1.100
(config-if)#encapsulation dot1q 100

在trunk介面指定native vlan
(config-if)switchport trunk native vlan < vlan id>
< vlan id>:指定不加tag的vlan,可設範圍為1-4096,預設為vlan1,以便trunk不起來時可連過去管理
若trunk失敗時,讓port屬於某vlan
各switch之native vlan為一個vlan網路,即使指定的native vlan id不同理論上也可在native vlan互通
ex:
switch1 trunk interface的native vlan為10
若switch2 native vlan(1) untage frame從trunk介面進來
switch1會認為是vlan10,所以switch2的frame只能在vlan 10活動 
ps:
You can bring up a trunk with different native VLANs on each end;
however, both switches will log error messages about the mismatch,and the potential exists that traffic will not pass correctly between the two native VLANs.
ex:
以下組織,可讓使用vlan1設備之流量可在2台switch間互通
switch 1互連介面為
 switchport trunk encapsulation dot1q(預設允許任何vlan)
switch 2互連介面為 
 switchport mode access
 switchport trunk native vlan 1(指定vlan 1不加tag)  
ps:
native VLAN mismatch is discovered through the exchange of CDP messages
ps:
在ISL trunk下,該指令無作用,因為ISL不支援untagged VLAN

定義可通過的vlan 
(config-if)# switchport trunk allowed vlan < vlan-list|all|< add|except|remove> vlan-list>
預設為all,vlan-id可支援1-4096 
相同指令會覆蓋
ex:
假設己allow vlan 2-4,則以下兩者結果相同
(config-if)# switchport trunk allowed vlan 2,4
(config-if)# switchport trunk allowed vlan remove 3
ps:
If one end of the trunk is configured to disallow a VLAN, that VLAN will not be contiguous across the trunk. 

…… 

trunk設定
有以下2方式
1手動設定2邊trunk
2透過DTP自動協商2邊trunk 

DTP(Dynamic Trunk Protocol,思科動態中繼傳輸協定)
思科專屬協定,用於自動協商2設備間是否要使用trunk
DTP frames are sent out every 30 seconds to keep neighboring switch ports informed of the link’s mode
ps:
在繁忙的網路中建議關閉此DTP功能,改以手動方式設定trunk 

將port mode設為trunk
(config-if)#switchport mode dynamic < auto|desirable>>
< trunk>:兩switch設定trunk可讓兩邊相同的vlan通訊,換句話說就是讓此埠同時成為多個vlan的一部份
ps:DTP is still operational on trunk mode,so if the far-end switch port is configured to trunk,dynamic desirable,or dynamic auto mode,trunking will be negotiated successfully.
< dynamic auto> :透過DTP配合對方改變,不主動request
< dynamic desirable>:(default),希望成為trunk,這會送出DTP的FRAME和對方設備做協調,看是否要成為TRUNK
兩介面經DTP配對結果如下:
trunk+access不會成為trunk
trunk+desirable會成為trunk
dynamic desirable+dynamic auto會成為trunk
dynamic auto+dynamic auto不一定,狀況無法判斷
ex:
手動建立trunk
在兩個已連線的switch fa0/12建立trunk
switch1:
(config)#int fa0/12
(config-if)#switchport mode trunk
switch2:
(config)#int fa0/12
(config-if)#switchport mode trunk 

關閉介面DTP運作
(config-if)#switchport nonegotiate
預設是啟動
若關閉則switchport mode dynamic將無法使用而無法request 
mode需為access或trunk才可使用

顯示dtp運作資訊
#show dtp [interface < interface>] 

ps:
1900switch的設定方式
(config-if)#trunk < act>
有以下act可選
on 開啟DISL,而且可和其他界面協商
off 關閉
nonegotiate 開啟DISL,但不和其他界面協商
desirable 若連到nonegotiate,auto,desirable則開啟DISL
auto 若連到on,desirable則開啟DISL

……………..

顯示trunk資訊
#show interface [interface] trunk
1
畫面大致如下:
#show interface trunk
Port Mode Encapsulation Status Native vlan
Fa0/12 on 802.1q trunking 1 //fa0/12介面為trunk mode,使用802.1q封裝
Port Vlans allowed on trunk  //可允許通過的vlan 
Fa0/12 none
Port Vlans allowed and active in management domain //目前正在活動中的vlan 
Fa0/12 none
Port Vlans in spanning tree forwarding state and not pruned //經stp及pruned後,實際可用的vlan
Fa0/12 none
2
若指定介面,畫面大致如下
#show interface fa0/2 trunk
Port Mode Encapsulation Status Native vlan
Fa0/2 auto 802.1q not-trunking 1
Port Vlans allowed on trunk
Fa0/2 1
Port Vlans allowed and active in management domain
Fa0/2 1
Port Vlans in spanning tree forwarding state and not pruned
Fa0/2 1
說明:目前fa0/2的port mode為autonegotiation,但沒協商成功所以不是trunk status

顯示switchport介面資訊 
#show interface [interface] switchport
ps:
show interface switchport為例,畫面大致如下
namee: Gi4/2
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk    //若為down表示介面沒在運作 
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)  //switchport trunk native vlan 1 (default) 
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL    //allow vlan = all
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
[omitted]
 


ps:
1900switch的設定方式為show trunk
畫面大致如下:
DISL state: on, Trunking: on, Encapsulation type: ISL //使用trunk的介面用isl封裝


……………………………………………………………………


vlan互連使用一條線在router上的設定
router(config-if)#no ip
router(config-if)#no shut
router(config-if)#int < sub-interface>
router(config-subif)#encapsulation < type> < vlan id>
router(config-subif)#ip addrress
< type>需和來源trunk port的encapsulation type相同
< vlan id>需和來源的vlan id相同
ps:連到router的switch port要設成trunk
ex:Switch建vlan2,3
Vlan2的gateway為192.168.2.1/24,Vlan3的gateway為192.168.3.1/24
switch fa0/2為vlan2,fa0/3為vlan3,fa0/12和Router fa0/1連結
Switch(config)#vlan 2
Switch(config)#vlan 3
Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#int fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 3
Switch(config-if)#int fa0/12
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#end
Router(config)#int fa0/1
Router(config-if)#no ip address
Router(config-if)#no sh
Router(config-if)#int fa0/1.2
Router(config-subif)#encapsulation dot1q 2
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-subif)#int fa0/1.3
Router(config-subif)#encapsulation dot1q 3
Router(config-subif)#ip address 192.168.3.1 255.255.255.0
Router(config-subif)#end

switch和router間trunk問題處理步驟
1 check實體層錯誤 ex:port是否有連接,fcs錯誤
2 check switch和router間兩端雙工和速度設定
3 check router的子界面 ex:正確的封裝型態,vlan id,ip address,netmask,…等
4 check ios version判斷界面是否支援vlan turnk

………………………………………………………………………………………………………………………….

ISL(Inter-Switch Link Protocol,交換器間鏈路通訊協定)
思科專屬VLAN傳輸協定,用於維護交換機和路由器間的通信流量等VLAN 訊息
主要攜帶vlan(虛擬網路)的相關資訊
提供交換器間傳送Ethernet訊框,FDDI訊框,Token-Ring訊框的服務
讓交換器間在多種網路模組下傳送各種訊框,支援vlan的服務
ps:
IEEE版本的vlan是802.1q,可支援多廠商
ISL Tagging能與802.1Q trunk執行相同工作,只是所採用的格式不同
ps:
並非所有catalyst switch都有支援特徵:
Catalyst switches使用ASIC執行 
不干涉客戶端機站,客戶端機不會看到ISL傳輸協定頭 
ISL NICs為交換機與交換機、路由器與交換機、交換機與伺服器等之間的執行提供高效效能  


功能
ISL tag採用一種Low-Latency(低延遲)機制為單個物理路徑上的多 VLANs 流量提供復用技術
ISL主要用於實現交換機、路由器以及各節點(如伺服器所使用的網路接頭卡)之間的連接操作
ISL所組態的路由器支持VLAN內通信服務,非ISL組態的設備,則用於接收由ISL封裝的Ethernet Frames
ps:
為支持 ISL 功能特徵,每台連接設備都必須採用 ISL 組態

運作方式
The packet is encapsulated with a 26 byte header and a 4 byte FCS
ISL作用於 OSI 模型第2層
ISL傳輸協定頭和尾封裝整個第2層的Ethernet Frames 
ISL被認為能在交換機間傳送第2層任何檔案類型的frame或上層傳輸協定的獨立傳輸協定 
ISL所封裝的frame可以是Token Ring或Fast Ethernet
ps:
若訊框要離開vlan會先移除掉ISL封裝 

ISL frame
30byte:由26-byte header和4-byte trailer所封裝
格式如下
[DA | TYPE | USER | SA | LEN | HSA | VLAN | BPDU] payload [FCS]
DA:目的地址,是一個組播位址,總是相同的40位01000C0000,告訴接收方該框訊是ISL格式封裝的。
TYPE:指明所封裝禎的類型,乙太網0000、權杖環網0001、FDDI網0010、ATM 0011
USER:用戶自定義
SA:發送該ISL框訊的交換機介面的48位元MAC位址
LEN:ISL框訊的長度 HSA:源位址高位,含生產商的ID和MAC源位址。以00000C開頭。
VLAN:15bit,VLAN的ID號
BPDU:如果是STP框訊就置該位的值
FCS:appends在paylod之後,用於CRC
ps:
frame增加30byte會超過mtu(1518byte)而產生 baby giant frames

DISL(動態交換鏈路內傳輸協定)
簡化了兩台相互連接的快速乙太網設備上 ISL 幹線的新增程序
DISL實現了最小化VLAN幹線,因為DISL中只允許將一個鏈路終端組態為幹線