19 · Implementing VLANs and Trunks實作 VLAN 與中繼

Trunking with 802.1Q使用 802.1Q 進行中繼

Without trunking, running many VLANs between switches would require the same number of interconnecting links.

若沒有中繼(trunking)功能,要在交換器之間傳輸多個 VLAN,就需要相同數量的互連線路。

If every port belongs to one VLAN and you have several VLANs that are configured on switches, then interconnecting them requires one physical cable per VLAN. When the number of VLANs increases, the number of required interconnecting links also increases. Ports are then used for interswitch connectivity instead of attaching end devices.

如果每個連接埠都只屬於一個 VLAN,而交換器上設定了多個 VLAN,那麼要互連這些交換器,每個 VLAN 都需要一條實體纜線。當 VLAN 數量增加時,所需的互連線路數量也會隨之增加。此時,連接埠會被用於交換器間的連線,而不是連接終端裝置。

Instead, you can use one connection configured as a trunk:

取而代之的做法是,使用一條設定為中繼的連線:

Characteristics of Trunking with 802.1Q include the following:

802.1Q 中繼的特性包括:

  • Combining many VLANs on the same port is called trunking.在同一個連接埠上結合多個 VLAN,稱為中繼(trunking)。
  • A trunk allows the transport of frames from different VLANs.中繼可讓來自不同 VLAN 的框架在同一連結上傳輸。
  • Each frame has a tag that specifies the VLAN that it belongs to.每個框架都有一個標籤,用來指明它所屬的 VLAN。
  • The receiving device forwards the frames to the corresponding VLAN based on the tag information.接收裝置會根據標籤資訊,將框架轉送到對應的 VLAN。

A trunk is a point-to-point link between two network devices such as a server, router and a switch. Ethernet trunks carry the traffic of multiple VLANs over a single link and allow you to extend the VLANs across an entire network. A trunk does not belong to a specific VLAN. Rather, it is a conduit for VLANs between devices. By default, all configured VLANs are carried over a trunk interface on a Cisco Catalyst switch.

中繼是兩個網路裝置(例如伺服器、路由器與交換器)之間的點對點連結。乙太網路中繼可在單一連結上承載多個 VLAN 的流量,讓你可以將 VLAN 延伸到整個網路。中繼本身並不屬於特定的 VLAN,而是各 VLAN 之間的傳輸通道。在 Cisco Catalyst 交換器上,預設情況下所有已設定的 VLAN 都會透過中繼介面傳輸。

VLAN Tagging

VLAN 標記

If your network includes VLANs that span multiple interconnected switches, the switches must use VLAN trunking on the connections between them. Switches use a process called VLAN tagging in which the sending switch adds another header to the frame before sending it over the trunk. This extra header is called a tag and includes a VID field so that the sending switch can list the VLAN ID and the receiving switch can identify the VLAN that each frame belongs to, as illustrated in the figure.

如果你的網路包含跨越多台互連交換器的 VLAN,這些交換器之間的連線就必須使用 VLAN 中繼。交換器會使用一種稱為 VLAN 標記(tagging)的程序,即傳送端交換器在將框架送上中繼連結前,會在框架中加入另一個標頭。這個額外的標頭稱為標籤(tag),其中包含一個 VID 欄位,讓傳送端交換器可以列出 VLAN ID,接收端交換器也能藉此識別每個框架所屬的 VLAN,如圖所示。

Trunking allows switches to pass frames from multiple VLANs over a single physical connection. For example, the figure shows Switch 1 receiving a broadcast frame on the Fa0/1 interface, which is a member of VLAN 1. In a broadcast, the frame must be forwarded to all ports in VLAN 1. Because there are ports on Switch 2 that are members of the VLAN 1 switch, the frame must be forwarded to Switch 2. Before forwarding the frame, Switch 1 adds a header that identifies the frame as belonging to VLAN 1. This header tells Switch 2 that the frame should be forwarded to the VLAN 1 ports. Switch 2 removes the header and then forwards the frame for all ports that are part of VLAN 1.

中繼可讓交換器在單一實體連線上傳遞來自多個 VLAN 的框架。舉例來說,圖中顯示交換器 1 在 Fa0/1 介面上收到一個廣播框架,該介面屬於 VLAN 1 的成員。在廣播情況下,此框架必須轉送到 VLAN 1 中的所有連接埠。由於交換器 2 上也有屬於 VLAN 1 的連接埠,因此該框架必須轉送到交換器 2。在轉送框架之前,交換器 1 會加入一個標頭,標明此框架屬於 VLAN 1。這個標頭告訴交換器 2,該框架應轉送到 VLAN 1 的連接埠。交換器 2 移除該標頭後,會將框架轉送給所有屬於 VLAN 1 的連接埠。

As another example, the device on the Switch 1 Fa0/5 interface sends a broadcast. Switch 1 sends the broadcast out of port Fa0/6 (because this port is in VLAN 2) and out Fa0/23 (because it is a trunk, meaning that it supports multiple VLANs). Switch 1 adds a trunking header to the frame, listing a VLAN ID of 2. Switch 2 strips off the trunking header, and because the frame is part of VLAN 2, Switch 2 knows to forward the frame out of only ports Fa0/5 and Fa0/6 and not ports Fa0/1 and Fa0/2.

再舉一例,交換器 1 上 Fa0/5 介面的裝置發出一個廣播。交換器 1 會將該廣播從 Fa0/6 連接埠送出(因為此連接埠屬於 VLAN 2),也會從 Fa0/23 送出(因為它是中繼埠,也就是支援多個 VLAN)。交換器 1 會在框架中加入中繼標頭,標示 VLAN ID 為 2。交換器 2 會移除該中繼標頭,並因為此框架屬於 VLAN 2,交換器 2 得知應僅將此框架轉送到 Fa0/5 與 Fa0/6 連接埠,而不轉送到 Fa0/1 與 Fa0/2 連接埠。

IEEE 802.1Q

IEEE 802.1Q

Cisco Catalyst switches support the IEEE 802.1Q trunking protocol.

Cisco Catalyst 交換器支援 IEEE 802.1Q 中繼協定。

When a switch puts an Ethernet frame on a trunk, it needs to add a VLAN tag with information about the VLAN to which the frame belongs. The switch does so by using the 802.1Q encapsulation header. IEEE 802.1Q uses an internal tagging mechanism that inserts an extra 4-byte tag field into the original Ethernet frame between the Source Address and Type or Length fields. As a result, the frame still has the original source and destination MAC addresses. Also, because the original header has been expanded, 802.1Q encapsulation forces a recalculation of the original frame check sequence (FCS) field in the Ethernet trailer, because the FCS is based on the content of the entire frame. It is the responsibility of the receiving Ethernet switch to look at the 4-byte tag field and determine where to deliver the frame.

當交換器要將乙太網路框架送上中繼連結時,需要在框架中加入一個 VLAN 標籤,其中包含該框架所屬 VLAN 的資訊。交換器是透過使用 802.1Q 封裝標頭來完成這項工作。IEEE 802.1Q 使用一種內部標記機制,在原始乙太網路框架的來源位址(Source Address)欄位與類型或長度(Type or Length)欄位之間,插入一個額外的 4 位元組標籤欄位。因此,該框架仍保有原始的來源與目的 MAC 位址。此外,由於原始標頭已被擴充,802.1Q 封裝會強制重新計算乙太網路尾端中原有的框架檢查序列(FCS)欄位,因為 FCS 是根據整個框架的內容計算而得。接收端乙太網路交換器有責任檢視這個 4 位元組標籤欄位,以決定該將框架傳送到何處。

The figure shows the 802.1Q header and framing of the revised Ethernet header.

此圖顯示 802.1Q 標頭,以及經修訂之乙太網路標頭的框架格式。

Here are tag fields:

以下是標籤欄位:

  • Type or tag protocol identifier is set to a value of 0x8100 to identify the frame as an IEEE 802.1Q-tagged frame.類型(Type)或標籤協定識別碼被設為 0x8100,用以識別此框架為 IEEE 802.1Q 已標記框架。
  • Priority indicates the frame priority level that can be used for the prioritization of traffic.優先權(Priority)指出可用於流量優先排序的框架優先層級。
  • Canonical Format Identifier (CFI) is a 1-bit identifier that enables Token Ring frames to be carried across Ethernet links標準格式識別碼(Canonical Format Identifier,CFI)是一個 1 位元的識別碼,可讓 Token Ring 框架在乙太網路連結上傳輸
  • VLAN ID uniquely identifies the VLAN to which the frame belongs.VLAN ID 用來唯一識別此框架所屬的 VLAN。

On an 802.1Q trunk port, there is one VLAN, called the native VLAN, which is untagged. By default, the native VLAN is VLAN 1, which means that the switch does not insert an extra 802.1Q tag inside an Ethernet frame. When the switch on the receiving side receives the Ethernet frame that does not have an 802.1Q tag, it knows that the frame belongs to the native VLAN. All other VLANs are tagged with a VID. IEEE 802.1Q specifies that native VLANs are backward compatible with legacy LAN scenarios, where untagged traffic is common.

在 802.1Q 中繼埠上,有一個 VLAN 是未標記的,稱為原生 VLAN(native VLAN)。預設情況下,原生 VLAN 是 VLAN 1,也就是說交換器不會在乙太網路框架中插入額外的 802.1Q 標籤。當接收端的交換器收到沒有 802.1Q 標籤的乙太網路框架時,就會知道該框架屬於原生 VLAN。所有其他 VLAN 都會以 VID 進行標記。IEEE 802.1Q 規定原生 VLAN 須向下相容於未標記流量常見的傳統 LAN 情境。

Refer to the example. PC1 sends a broadcast. Which PCs will receive a copy of the broadcast frame?參考此範例。PC1 發出一個廣播。哪些 PC 會收到該廣播框架的副本?