本檔案將介紹Catalyst交換器上的VLAN主幹通訊協定(VTP)組態。
本文件沒有特定需求。
本檔案涵蓋各種Catalyst交換器型號,並不限於特定軟體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
VTP 可減少交換網路的管理工作。若在一台 VTP 伺服器上設定新的 VLAN,會將 VLAN 分配至網域中的所有交換器。這可減少到處設定相同 VLAN 的必要。VTP 是思科專有的通訊協定,適用於大部分的 Cisco Catalyst 系列產品。
如需VTP的詳細資訊,請參閱瞭解VLAN中繼線通訊協定(VTP)。
本節提供幾項準則,協助您設定網路的 VTP。
除非網路設計要求不同的VTP域,否則所有交換機都必須共用相同的VTP域名
VTP 網域中的所有交換器都必須執行相同 VTP 版本。
如果 VTP 網域中的交換器有 VTP 密碼,則所有交換器也都使用相同密碼。
對於VTP第1版和第2版,在將交換機連線到現有VTP域之前,請檢驗配置修訂版。如果處於VTP伺服器或客戶端模式的交換機具有更高的配置修訂版並匹配VTP域名和口令,則在配置時可能會導致其他交換機替換其VLAN資料庫。在連線交換機之前,請使用平台支援的過程將配置修訂版重置為0。
如果將交換機配置為VTP透明模式,則可以建立和修改VLAN,但這些更改不會傳送到域中的其他交換機,它們只影響單個交換機。
附註:對於需要VTP的新部署,請在支援的平台和軟體版本上使用VTP版本3。從VTP版本1或2遷移之前,驗證平台相容性和部署要求。
本節提供幾組基本命令,以便您在最常用的 Catalyst switch 上設定 VTP。
本節介紹兩種配置VTP的方法。方法可用性取決於Catalyst平台和Cisco IOS軟體版本。僅在支援此舊版方法的版本上使用VLAN資料庫模式。在支援的當前版本上使用全域性配置模式。
方法1. VLAN資料庫模式(傳統)
在支援的傳統Cisco IOS軟體版本中,您可以在VLAN資料庫模式下配置VTP域名、VTP模式和VLAN。
在EXEC模式下,運行此命令可進入VLAN資料庫模式:
Switch#vlan database !--- Issue this command in privileged EXEC mode, !--- not in global configuration mode. Switch(vlan)# !--- This is VLAN configuration mode.
發出以下命令,以便設定 VTP 網域名稱:
Switch(vlan)#vtp domain example
發出以下命令,以便設定 VTP 模式:
Switch(vlan)#vtp {client | server | transparent}
發出 exit 命令,以便退出 VLAN 組態模式。
Switch(vlan)#end Switch(vlan)#^Z % Invalid input detected at '^' marker. Switch(vlan)# Swtch(vlan)#exit APPLY completed. Exiting.... Switch#
方法2.全域性配置模式
在Cisco IOS和Cisco IOS XE全域性配置模式下,可以通過運行以下命令配置所有VTP引數:
Switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#vtp ? domain Set the name of the VTP administrative domain. file Configure IFS filesystem file where VTP configuration is stored. interface Configure interface as the preferred source for the VTP IP updater address. mode Configure VTP device mode password Set the password for the VTP administrative domain pruning Set the administrative domain to permit pruning version Set the administrative domain to VTP version Switch(config)#vtp domain ? WORD The ascii name for the VTP administrative domain. Switch(config)#vtp domain example Changing VTP domain name from example to example Switch(config)#vtp mode server Switch(config)#end
運行以下命令以驗證VTP操作和狀態:
Switch#show vtp status VTP Version capable : 1 to 3 VTP version running : 2 VTP Domain Name : example VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : 6400.f13e.dc40 Configuration last modified by 10.122.190.226 at 0-0-00 00:00:00 Local updater ID is 10.122.190.226 on interface Fa1 (first layer3 interface found) Feature VLAN: -------------- VTP Operating Mode : Server Maximum VLANs supported locally : 1005 Number of existing VLANs : 16 Configuration Revision : 0 MD5 digest : 0x0A 0xF4 0xFD 0xE9 0x99 0xD7 0xAB 0x3F 0x0A 0x64 0x04 0x7C 0x42 0x98 0xD8 0xE5 Switch# Switch#show vtp counters VTP statistics: Summary advertisements received : 0 Subset advertisements received : 0 Request advertisements received : 0 Summary advertisements transmitted : 0 Subset advertisements transmitted : 0 Request advertisements transmitted : 0 Number of config revision errors : 0 Number of config digest errors : 0 Number of V1 summary errors : 0 VTP pruning statistics: Trunk Join Transmitted Join Received Summary advts received from non-pruning-capable device ---------------- ---------------- ---------------- --------------------------- Switch#
範例1。此範例包括兩個透過TenGigabitEthernet連結連線的Catalyst 4500交換器:
步驟1.交換機A是沒有VTP域名且沒有使用者配置VLAN的新交換機。交換器 C 是現存的交換器,在 VTP 網域測試中執行 16 個 VLAN。
步驟2.在 show vtp status命令的輸出示例中,可以看到VTP版本預設為1。交換機A支援VTP V2。不過,此交換器在本例中並非執行 VTP V2。V2 版本必須以 vtp version 2 命令設定,該交換器才會僅執行 VTP V2。在此範例中,交換器 A 設為 VTP 用戶端。將交換機連線到VTP域之前,請確保其VTP模式、版本、域名、口令和配置修訂版是正確的。對於VTP版本1和2,請使用平台支援的過程重置配置修訂版,並驗證修訂版是0或者其值低於連線前的當前VTP伺服器。
Switch-A#show vtp status VTP Version capable : 1 to 3 VTP version running : 1 VTP Domain Name : VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : 6400.f13e.dc40 Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00 Local updater ID is 10.122.190.226 on interface Fa1 (first layer3 interface found) Feature VLAN: -------------- VTP Operating Mode : Server Maximum VLANs supported locally : 1005 Number of existing VLANs : 5 Configuration Revision : 0 MD5 digest : 0x57 0xCD 0x40 0x65 0x63 0x59 0x47 0xBD 0x56 0x9D 0x4A 0x3E 0xA5 0x69 0x35 0xBC Switch-A# Switch-A# Switch-A# Switch-A#show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Gi1/1, Gi1/2, Gi1/4, Gi1/5 Gi1/6, Gi1/7, Gi1/8, Gi1/9 Gi1/10, Gi1/11, Gi1/12, Gi1/13 Gi1/14, Gi1/15, Gi1/16, Gi1/17 Gi1/18, Gi1/19, Gi1/20, Gi1/21 Gi1/22, Gi1/23, Gi1/24, Gi1/25 Gi1/26, Gi1/27, Gi1/28, Gi1/29 Gi1/30, Gi1/31, Gi1/32, Gi1/33 Gi1/34, Gi1/35, Gi1/36, Gi1/37 Gi1/38, Gi1/39, Gi1/40, Gi1/41 Gi1/42, Gi1/43, Gi1/44, Gi1/45 Gi1/46, Gi1/47, Gi1/48, Te3/2 Te3/3, Te3/4, Te3/5, Te3/6 Te3/7, Te3/8 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup Switch-A#Switch-C#show vtp status VTP Version capable : 1 to 3 VTP version running : 2 VTP Domain Name : test VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : 503d.e583.3b40 Configuration last modified by 10.122.190.227 at 11-24-22 13:44:22 Local updater ID is 10.122.190.227 on interface Fa1 (first layer3 interface found) Feature VLAN: -------------- VTP Operating Mode : Server Maximum VLANs supported locally : 1005 Number of existing VLANs : 16 Configuration Revision : 4 MD5 digest : 0xCB 0x67 0x2A 0xF1 0x9A 0x8D 0xD3 0x1B 0xA8 0xB3 0x89 0xB2 0x32 0x63 0xA6 0xD0 Switch-C# Switch-C#show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Gi1/1, Gi1/2, Gi1/3, Gi1/4 Gi1/5, Gi1/6, Gi1/7, Gi1/8 Gi1/9, Gi1/10, Gi1/11, Gi1/12 Gi1/13, Gi1/14, Gi1/15, Gi1/16 Gi1/17, Gi1/18, Gi1/19, Gi1/20 Gi1/21, Gi1/22, Gi1/23, Gi1/24 Gi1/25, Gi1/26, Gi1/27, Gi1/28 Gi1/29, Gi1/30, Gi1/31, Gi1/32 Gi1/33, Gi1/34, Gi1/35, Gi1/36 Gi1/37, Gi1/38, Gi1/39, Gi1/40 Gi1/41, Gi1/42, Gi1/43, Gi1/44 Gi1/45, Gi1/46, Gi1/47, Gi1/48 Te3/2, Te3/3, Te3/4, Te3/5 Te3/6, Te3/7, Te3/8 2 VLAN0002 active 3 VLAN0003 active 4 VLAN0004 active 5 VLAN0005 active 6 VLAN0006 active 7 VLAN0007 active VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 8 VLAN0008 active 9 VLAN0009 active 10 VLAN0010 active 11 VLAN0011 active 12 VLAN0012 active 1002 fddi-default act/unsup 1003 trcrf-default act/unsup 1004 fddinet-default act/unsup 1005 trbrf-default act/unsup Switch-C#Switch-A# Switch-A#configure terminal Switch-A(config)#vtp version 2 Switch-A(config)#vtp mode client Setting device to VTP Client mode for VLANS. Switch-A(config)#end Switch-A#
Switch-A#show vtp status VTP Version capable : 1 to 3 VTP version running : 2 VTP Domain Name : VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : 6400.f13e.dc40 Configuration last modified by 10.122.190.226 at 11-25-22 02:34:10 Feature VLAN: -------------- VTP Operating Mode : Client Maximum VLANs supported locally : 1005 Number of existing VLANs : 5 Configuration Revision : 1 MD5 digest : 0xD2 0x3F 0x31 0x25 0x6D 0xD1 0x3E 0x27 0x62 0x77 0x7C 0xAF 0x0F 0xF6 0x72 0x02 Switch-A#
步驟3.在此階段,兩台交換器之間手動建立主幹。請注意兩者的同步方式,並觀察 VTP 封包如何交換:
附註:調試輸出增加了處理器和日誌記錄活動。必須在受控環境中運行這些命令。
Switch-A#debug sw-vlan vtp events vtp events debugging is on Switch-A#debug sw-vlan vtp packets vtp packets debugging is on Switch-A#Switch-A#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch-A(config)#interface tenGigabitEthernet3/2 Switch-A(config-if)#no shut Switch-A(config-if)#end Switch-A#
步驟4.交換機C向交換機A傳送總結通告。交換器 A 接著會從通告中得知 VTP 網域名稱,如以下輸出範例所示:
!--- On Switch-A:*Nov 25 02:45:46.580: VTP LOG RUNTIME: switchport trunk mode on Te3/2 has changed *Nov 25 02:45:46.580: VTP LOG RUNTIME: delaying first flood on new trunk *Nov 25 02:45:51.100: VTP LOG RUNTIME: Summary packet received in NULL domain state *Nov 25 02:45:51.100: VTP LOG RUNTIME: Summary packet received, domain = test, rev = 4, followers = 0, length 80, trunk Te3/2
!--- This indicates that Switch-A has received its first summary advertisement.*Nov 25 02:45:51.100: VTP LOG RUNTIME: Validate TLVs : #tlvs 1, max blk size 4 *Nov 25 02:45:51.100: VTP LOG RUNTIME: Validate TLVs : #00, val 6, len 4 *Nov 25 02:45:51.100: *Nov 25 02:45:51.100: summary: 02 01 00 04 74 65 73 74 00 00 00 00 00 00 00 00 ....test........ *Nov 25 02:45:51.100: summary: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *Nov 25 02:45:51.100: summary: 00 00 00 00 00 00 00 04 0A 7A BE E3 32 32 31 31 .........z>c2211 *Nov 25 02:45:51.100: summary: 32 34 31 34 30 31 31 35 8D 07 FE 82 E5 FE 49 AD 24140115..~.e~I- *Nov 25 02:45:51.100: summary: 1A 6E A5 AB D0 35 C2 CA 00 00 00 01 06 01 00 02 .n%+P5BJ........ *Nov 25 02:45:51.100: *Nov 25 02:45:51.108: VTP LOG RUNTIME: Transitioning from NULL to test domain
!--- Switch-A learns the VTP domain at this stage.
步驟5.啟用偵錯後,您可以看到交換器A收到沒有跟隨者的總結通告。因此,交換器 A 會更新網域名稱,並傳送通告請求,以便取得 VLAN 資訊,如以下輸出範例所示:
!--- On Switch-A*Nov 25 02:45:51.108: VTP LOG RUNTIME: Summary packet rev 4 greater than domain test rev 0 *Nov 25 02:45:51.108: VTP LOG RUNTIME: Domain test currently not in updating state *Nov 25 02:45:51.108: VTP LOG RUNTIME: Summary packet with followers field zero *Nov 25 02:45:51.108: VTP LOG RUNTIME: Transmit vtp request, domain test, start value 0
!--- This is where the advertisement request is sent.
步驟6.交換機C傳送另一條跟隨者欄位設定為1的彙總通告,這表示後面有一個子集通告。包含所有VLAN的子集通告將顯示在此輸出中。交換器 A 接著會設定所有 VLAN:
!--- On Switch-A:*Nov 25 02:45:51.595: VTP LOG RUNTIME: Summary packet received, domain = test, rev = 4, followers = 1, length 80, trunk Te3/2!--- Switch-A has received its second summary advertisement.!--- This configuration revision is higher than that on Switch-A.*Nov 25 02:45:51.595: VTP LOG RUNTIME: Validate TLVs : #tlvs 1, max blk size 4 *Nov 25 02:45:51.595: VTP LOG RUNTIME: Validate TLVs : #00, val 6, len 4 *Nov 25 02:45:51.595: *Nov 25 02:45:51.596: summary: 02 01 01 04 74 65 73 74 00 00 00 00 00 00 00 00 ....test........ *Nov 25 02:45:51.596: summary: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *Nov 25 02:45:51.596: summary: 00 00 00 00 00 00 00 04 0A 7A BE E3 32 32 31 31 .........z>c2211 *Nov 25 02:45:51.596: summary: 32 34 31 34 30 31 31 35 8D 07 FE 82 E5 FE 49 AD 24140115..~.e~I- *Nov 25 02:45:51.596: summary: 1A 6E A5 AB D0 35 C2 CA 00 00 00 01 06 01 00 02 .n%+P5BJ........ *Nov 25 02:45:51.596: *Nov 25 02:45:51.596: VTP LOG RUNTIME: Summary packet rev 4 greater than domain test rev 0 *Nov 25 02:45:51.596: VTP LOG RUNTIME: Domain test currently not in updating state *Nov 25 02:45:51.596: VTP LOG RUNTIME: pdu len 80, #tlvs 1 *Nov 25 02:45:51.596: VTP LOG RUNTIME: Subset packet received, domain = test, rev = 4, seq = 1, length = 420!--- Switch-A has received its subset advertisement.*Nov 25 02:45:51.596: subset: 02 02 01 04 74 65 73 74 00 00 00 00 00 00 00 00 ....test........ *Nov 25 02:45:51.596: subset: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *Nov 25 02:45:51.596: subset: 00 00 00 00 00 00 00 04 14 00 01 07 00 01 05 DC ...............\ *Nov 25 02:45:51.596: subset: 00 01 86 A1 64 65 66 61 75 6C 74 00 14 00 01 08 ...!default..... *Nov 25 02:45:51.596: subset: 00 02 05 DC 00 01 86 A2 56 4C 41 4E 30 30 30 32 ...\..."VLAN0002 *Nov 25 02:45:51.596: subset: 14 00 01 08 00 03 05 DC 00 01 86 A3 56 4C 41 4E .......\...#VLAN *Nov 25 02:45:51.596: subset: 30 30 30 33 14 00 01 08 00 04 05 DC 00 01 86 A4 0003.......\...$ *Nov 25 02:45:51.596: subset: 56 4C 41 4E 30 30 30 34 14 00 01 08 00 05 05 DC VLAN0004.......\ *Nov 25 02:45:51.596: subset: 00 01 86 A5 56 4C 41 4E 30 30 30 35 14 00 01 08 ...%VLAN0005.... *Nov 25 02:45:51.596: subset: 00 06 05 DC 00 01 86 A6 56 4C 41 4E 30 30 30 36 ...\...&VLAN0006 *Nov 25 02:45:51.596: subset: 14 00 01 08 00 07 05 DC 00 01 86 A7 56 4C 41 4E .......\...'VLAN *Nov 25 02:45:51.596: subset: 30 30 30 37 14 00 01 08 00 08 05 DC 00 01 86 A8 0007.......\...( *Nov 25 02:45:51.596: subset: 56 4C 41 4E 30 30 30 38 14 00 01 08 00 09 05 DC VLAN0008.......\ *Nov 25 02:45:51.596: subset: 00 01 86 A9 56 4C 41 4E 30 30 30 39 14 00 01 08 ...)VLAN0009.... *Nov 25 02:45:51.596: subset: 00 0A 05 DC 00 01 86 AA 56 4C 41 4E 30 30 31 30 ...\...*VLAN0010 *Nov 25 02:45:51.596: subset: 14 00 01 08 00 0B 05 DC 00 01 86 AB 56 4C 41 4E .......\...+VLAN *Nov 25 02:45:51.596: subset: 30 30 31 31 14 00 01 08 00 0C 05 DC 00 01 86 AC 0011.......\..., *Nov 25 02:45:51.596: subset: 56 4C 41 4E 30 30 31 32 18 00 02 0C 03 EA 05 DC VLAN0012.....j.\ *Nov 25 02:45:51.596: subset: 00 01 8A 8A 66 64 64 69 2D 64 65 66 61 75 6C 74 ....fddi-default *Nov 25 02:45:51.596: subset: 30 00 03 0D 03 EB 11 78 00 01 8A 8B 74 72 63 72 0....k.x....trcr *Nov 25 02:45:51.596: subset: 66 2D 64 65 66 61 75 6C 74 00 00 00 01 01 0C CC f-default......L *Nov 25 02:45:51.596: subset: 04 01 03 ED 07 01 00 02 08 01 00 07 09 01 00 07 ...m............ *Nov 25 02:45:51.596: subset: 20 00 04 0F 03 EC 05 DC 00 01 8A 8C 66 64 64 69 ....l.\....fddi *Nov 25 02:45:51.596: subset: 6E 65 74 2D 64 65 66 61 75 6C 74 00 03 01 00 01 net-default..... *Nov 25 02:45:51.596: subset: 24 00 05 0D 03 ED 11 78 00 01 8A 8D 74 72 62 72 $....m.x....trbr *Nov 25 02:45:51.596: subset: 66 2D 64 65 66 61 75 6C 74 00 00 00 02 01 00 0F f-default....... *Nov 25 02:45:51.596: subset: 03 01 00 02 .... *Nov 25 02:45:51.596: *Nov 25 02:45:51.666: VTP LOG RUNTIME: Transmit vtp summary, domain test, rev 4, followers 1, tlv blk size 8 (inc #tlv field), MD5 digest calculated = 8D 07 FE 82 E5 FE 49 AD 1A 6E A5 AB D0 35 C2 CA
步驟7.此時,兩台交換器均同步:
Switch-A#show vtp status VTP Version capable : 1 to 3 VTP version running : 2 VTP Domain Name : test VTP Pruning Mode : Disabled VTP Traps Generation : Disabled Device ID : 6400.f13e.dc40 Configuration last modified by 10.122.190.227 at 11-24-22 14:01:15 Feature VLAN: -------------- VTP Operating Mode : Client Maximum VLANs supported locally : 1005 Number of existing VLANs : 16 Configuration Revision : 4 MD5 digest : 0x8D 0x07 0xFE 0x82 0xE5 0xFE 0x49 0xAD 0x1A 0x6E 0xA5 0xAB 0xD0 0x35 0xC2 0xCA Switch-A#show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Gi1/1, Gi1/2, Gi1/4, Gi1/5 Gi1/6, Gi1/7, Gi1/8, Gi1/9 Gi1/10, Gi1/11, Gi1/12, Gi1/13 Gi1/14, Gi1/15, Gi1/16, Gi1/17 Gi1/18, Gi1/19, Gi1/20, Gi1/21 Gi1/22, Gi1/23, Gi1/24, Gi1/25 Gi1/26, Gi1/27, Gi1/28, Gi1/29 Gi1/30, Gi1/31, Gi1/32, Gi1/33 Gi1/34, Gi1/35, Gi1/36, Gi1/37 Gi1/38, Gi1/39, Gi1/40, Gi1/41 Gi1/42, Gi1/43, Gi1/44, Gi1/45 Gi1/46, Gi1/47, Gi1/48, Te3/3 Te3/4, Te3/5, Te3/6, Te3/7 Te3/8 2 VLAN0002 active 3 VLAN0003 active 4 VLAN0004 active 5 VLAN0005 active 6 VLAN0006 active 7 VLAN0007 active VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 8 VLAN0008 active 9 VLAN0009 active 10 VLAN0010 active 11 VLAN0011 active 12 VLAN0012 active 1002 fddi-default act/unsup 1003 trcrf-default act/unsup 1004 fddinet-default act/unsup 1005 trbrf-default act/unsup
附註:收集所需的輸出後,使用undebug all命令禁用VTP調試條件,並驗證調試是否不再處於活動狀態。
範例2.此範例顯示如何驗證VTP版本是否執行以及配置修訂版號:
Switch#show vtp status
VTP Version capable : 1 to 3
VTP version running : 2
VTP Domain Name : Lab_Network
VTP Pruning Mode : Disabled (Operationally Disabled)
VTP Traps Generation : Disabled
Device ID : f87a.41a8.ca00
Configuration last modified by 10.10.10.2 at 8-17-26 20:47:55
Local updater ID is 10.10.10.2 on interface Vl10 (lowest numbered VLAN interface found)
Feature VLAN:
--------------
VTP Operating Mode : Server
Maximum VLANs supported locally : 1005
Number of existing VLANs : 6
Configuration Revision : 1
MD5 digest : 0xFD 0x47 0xA0 0x3D 0x02 0x88 0x96 0x04
0x52 0xDE 0x4D 0x51 0x6A 0x5E 0xEC 0x49
示例3.此示例說明如何顯示VTP統計資訊:
Swtich#show vtp counters
VTP statistics:
Summary advertisements received : 0
Subset advertisements received : 0
Request advertisements received : 0
Summary advertisements transmitted : 2
Subset advertisements transmitted : 2
Request advertisements transmitted : 10
Number of config revision errors : 0
Number of config digest errors : 0
Number of V1 summary errors : 0
VTP pruning statistics:
Trunk Join Transmitted Join Received Summary advts received from
non-pruning-capable device
---------------- ---------------- ---------------- ---------------------------
Te1/1/6 0 0 0
| 修訂 | 發佈日期 | 意見 |
|---|---|---|
5.0 |
18-Aug-2026
|
重新認證 — 更新的參與者清單和格式。 |
4.0 |
10-Jul-2025
|
已更新連結標題和格式。 |
3.0 |
27-Feb-2024
|
已更新CLI輸出、樣式要求、SEO、語法和格式。 |
2.0 |
24-Nov-2022
|
更新的CLI輸出 |
1.0 |
29-Jul-2007
|
初始版本 |