This topic describes how to configure an 802.1Q trunk.
本主題說明如何設定 802.1Q 中繼。
The following example shows the configuration of interface Ethernet0/0 as a trunk. Use the switchport mode interface configuration command to set an Ethernet port to trunk mode. The example also shows reconfiguration of the native VLAN. VLAN 99 is configured as the native VLAN; therefore, traffic from VLAN 99 is sent untagged. You must ensure that the switch on the other end of the trunk link is configured the same way.
以下範例顯示將 Ethernet0/0 介面設定為中繼埠的方式。使用介面設定指令 switchport mode 可將乙太網路連接埠設為中繼模式。此範例也顯示了重新設定原生 VLAN 的方式。VLAN 99 被設定為原生 VLAN,因此來自 VLAN 99 的流量會以未標記方式傳送。你必須確保中繼連結另一端的交換器也採用相同方式設定。
If you do not explicitly configure the VLANs that traverse the trunk, all VLANs will be allowed to cross the link. Use the switchport mode trunk allowed vlan vlan_list command to allow only certain VLANs on the trunk link. In the example, only VLANs 10, 20, 30, and 99 are allowed on a trunk link. If you need to add or remove allowed VLANs, use the switchport trunk allowed vlan {add | remove} vlan_list command.
如果你未明確設定要通過此中繼的 VLAN,則所有 VLAN 都會被允許通過此連結。使用 switchport mode trunk allowed vlan vlan_list 指令可只允許特定 VLAN 通過中繼連結。在此範例中,只有 VLAN 10、20、30 與 99 被允許通過此中繼連結。若你需要新增或移除已允許的 VLAN,可使用 switchport trunk allowed vlan {add | remove} vlan_list 指令。
The table lists commands to use when creating a trunk port:
下表列出建立中繼埠時使用的指令:
Command and Variable 指令與變數 | Description 說明 |
interface interfaceinterface interface | Enters the interface configuration mode. 進入介面設定模式。 |
switchport mode trunkswitchport mode trunk | Sets the interface type to trunking. 將介面類型設為中繼。 |
switchport trunk native vlanvlan_numberswitchport trunk native vlanvlan_number | Sets the native VLAN on the trunk to the specified VLAN number. Traffic from this VLAN is sent untagged. Ensure that the switch on the other end of the trunk link is configured the same way. 將中繼上的原生 VLAN 設為指定的 VLAN 編號。此 VLAN 的流量會以未標記方式傳送。請確保中繼連結另一端的交換器也採用相同方式設定。 |
switchport trunk allowed vlan vlan_listswitchport trunk allowed vlan vlan_list | Sets allowed VLANs on a trunk link. vlan_list is a sequence of VLAN numbers, separated with commas. The vlan_list cannot have spaces after commas. 設定中繼連結上允許的 VLAN。vlan_list 是一連串以逗號分隔的 VLAN 編號。vlan_list 在逗號後面不可有空格。 |
switchport trunk allowed vlan add vlan_listswitchport trunk allowed vlan add vlan_list | Adds specified VLANs to the existing list of allowed VLANs on a trunk link. The vlan_list cannot have spaces after commas. 將指定的 VLAN 新增到中繼連結現有的允許 VLAN 清單中。vlan_list 在逗號後面不可有空格。 |
switchport trunk allowed vlan remove vlan_listswitchport trunk allowed vlan remove vlan_list | Removes specified VLANs from the existing list of allowed VLANs on a trunk link. The vlan_list cannot have spaces after commas. 從中繼連結現有的允許 VLAN 清單中移除指定的 VLAN。vlan_list 在逗號後面不可有空格。 |
The following example shows you how to verify the configuration of a trunked interface using the show interfaces interface-id switchport command.
以下範例說明如何使用 show interfaces interface-id switchport 指令來驗證中繼介面的設定。
In the example, you can see that the interface Ethernet 0/0 operates as a trunk port and has the VLAN 99 as the native VLAN. It only allows VLANs 10, 20, 30, and 99 to traverse through the link.
在此範例中,你可以看到介面 Ethernet 0/0 以中繼埠方式運作,並將 VLAN 99 設為原生 VLAN。它只允許 VLAN 10、20、30 與 99 通過此連結。
To verify, which ports are configured as trunks on a switch, you can use the show interfaces trunk command.
若要驗證交換器上哪些連接埠設定為中繼埠,可使用 show interfaces trunk 指令。
You can also use the show interfaces status command to quickly verify which port is a trunk, and which port belongs to a certain VLAN.
你也可以使用 show interfaces status 指令,快速驗證哪個連接埠是中繼埠,以及哪個連接埠屬於特定 VLAN。
Unlike access ports, when a port is configured as trunk port, it will not be seen under the show vlan [brief] command. Notice that, in this example, interface Ethernet 0/0 is missing.
與存取埠不同,當連接埠設定為中繼埠時,它不會出現在 show vlan [brief] 指令的輸出中。請注意,在此範例中,介面 Ethernet 0/0 並未列出。
SwitchX# SwitchX# show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Et0/2, Et0/3
2 SALES active Et0/1
10 VLAN0010 active
20 VLAN0020 active
30 VLAN0030 active
99 VLAN0099 active
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup