簡介
本文件說明如何使用 Cisco Catalyst 系列交換器設定 InterVLAN 路由。
必要條件
需求
嘗試此組態設定之前,請確保您符合以下需求:
採用元件
本文中的資訊係根據以下軟體和硬體版本:
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
慣例
如需文件慣例的詳細資訊,請參閱思科技術提示慣例。
相關產品
此組態也可以搭配以下軟硬體版本使用:
背景資訊
本文件提供範例組態,以說明在一般的網路情況下,如何透過 Catalyst 3850 系列交換器來設定 InterVLAN 路由。本文件使用兩台 Catalyst 4500 系列交換器作為直接連接 Catalyst 3850 的第 2 層 (L2) 交換器。Catalyst 3850 組態亦擁有預設路由,可在下一個躍點指向思科路由器時,路由所有前往網際網路的流量。您可以使用防火牆或其他路由器機型取代網際網路閘道。
附註:來自Internet網關路由器的配置不相關,因此本文檔不介紹該配置。
在交換式網路中,VLAN 可以將裝置分散至不同的衝突網域與第 3 層 (L3) 子網路中。VLAN 中的裝置可以彼此通訊,無須路由。位於不同 VLAN 中的裝置需要路由裝置才能彼此通訊。
僅L2交換機需要L3路由裝置來提供VLAN之間的通訊。裝置位於交換器外部或者在相同機箱的其他模組當中。新型交換機將路由功能整合到交換機中。以 3850 為例。交換器收到封包後,會判斷封包是否屬於其他 VLAN,並將封包傳送至目的地 VLAN 的適當連接埠。
一般的網路設計會根據裝置所屬的群組或功能來劃分網路。例如,工程VLAN只具有與工程部門相關的裝置,而財務VLAN只具有與財務相關的裝置。如果啟用路由,每個VLAN中的裝置可以相互通訊,而無需所有裝置都位於同一個廣播域中。這樣的 VLAN 設計也具有額外的優勢。此設計可讓管理員使用存取清單來限制 VLAN 之間的通訊。例如,您可以使用存取清單來限制工程設計 VLAN 存取財務 VLAN 上的裝置。
請參閱本文件,瞭解如何在 Catalyst 3550 系列交換器上設定 InterVLAN 路由的詳細資訊:如何在第 3 層交換器上設定 InterVLAN 路由。
設定
本節提供用於設定本文件中所述功能的資訊。
附註:使用思科支援工具可找到此處所用命令的詳細資訊。只有註冊的思科使用者有權存取這類工具以及其他內部資訊。
網路圖表
此文件使用以下網路設定:

在此圖中,Catalyst 3850的小示例網路提供了不同網段之間的VLAN間路由。Catalyst 3850交換機可以用作停用IP路由的L2裝置。為了讓交換器作為 L3 裝置並提供 InterVLAN 路由,請確認該 IP 路由已全域啟用。
以下是該使用者所定義的三個 VLAN:
-
VLAN 2 — User-VLAN
-
VLAN 3 — Server-VLAN
-
VLAN 10 — Mgmt-VLAN
每個伺服器與主機裝置上的預設閘道組態,必須為對應至 3850 的 VLAN 介面 IP 位址。例如,對於伺服器,預設網關為10.1.3.1。接入層交換機(即Catalyst 4500)將中繼到Catalyst 3850交換機。
Catalyst 3850 的預設路由會指向思科路由器,這是用來路由以網際網路為目的地的流量。因此,在路由表中沒有路由的 3850 的流量,會轉送至思科路由器進行額外程序。
實用祕訣
-
確保802.1Q TRUNK的本地VLAN在TRUNK鏈路的兩端相同。如果中繼一端的本地VLAN與另一端的本地VLAN不同,則兩端的本地VLAN的流量將無法在TRUNK上正確傳輸。無法正確傳輸即表示您的網路中發生了某些連線問題。
-
將管理 VLAN 與使用者或伺服器 VLAN 分開,如此圖表所示。管理 VLAN 有別於使用者或伺服器 VLAN。分開後,在使用者或伺服器 VLAN 中發生的任何廣播/封包風暴,都不會影響到交換器的管理作業。
-
請勿使用 VLAN 1 進行管理。Catalyst交換器中的所有連線埠預設為VLAN 1,而連線到未設定連線埠的任何裝置都位於VLAN 1中。使用VLAN 1進行管理可能會導致交換器的管理出現問題。
-
使用第 3 層(路由)連接埠連接至預設閘道連接埠。在此範例中,您可以輕鬆地更換具有防火牆,並連接至網際網路閘道路由器的思科路由器。
-
此示例在3850上配置一條通往Cisco路由器的靜態預設路由以訪問Internet。如果僅一個路由連接至網際網路,此設定就是最佳設定。確保在網關路由器上為Catalyst 3850可到達的子網配置靜態路由(最好是總結路由)。此步驟十分重要,因為此組態不使用路由通訊協定。
-
如果您的網路有兩台 Catalyst 3850 交換器,您可以將存取層交換器雙重連接至 3850 交換器,然後在交換器之間執行熱待命路由器通訊協定 (HSRP),以便在網路中提供備援。
-
如果您需要額外的頻寬用於上行鏈路連接埠,可以設定 EtherChannel。EtherChannel 也提供連結備援,以防連結失效。
組態
本文件使用以下組態:
-
Catalyst 3850
-
Catalyst 4500-A
-
Catalyst 4500-B
Catalyst 3850 |
SW_3850#show running-config
Building configuration...
Current configuration : 11543 bytes
!
! Last configuration change at 12:16:54 UTC Tue Nov 15 2022
!
version 16.12
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
service internal
service call-home
no platform punt-keepalive disable-kernel-core
!
hostname SW_3850
! !--- IP routing enabled for Inter VLAN routing.
ip routing
!
!
no ip domain lookup
!
!
login on-success log
!
!
!
vtp mode off ! !--- Output suppressed.
!--- Configure IEEE 802.1q trunks. !--- Issue the switchport mode trunk command to force the switch port to trunk mode. !--- Note: The default trunking mode is dynamic auto. If you establish a trunk link !--- with the default trunking mode, the trunk does not appear !--- in the configuration, even though a trunk has been established on !--- the interface. Use the show interfaces trunk command to verify the !--- establishment of the trunk.
!
interface GigabitEthernet1/0/1
shutdown
!
interface GigabitEthernet1/0/2
shutdown
!
interface GigabitEthernet1/0/3
description To_Switch-B
switchport mode trunk
!
interface GigabitEthernet1/0/4
no switchport
no ip address
shutdown ! interface GigabitEthernet1/0/5 description To_Switch-A switchport mode trunk ! interface GigabitEthernet1/0/6 no switchport no ip address shutdown
!
interface Vlan1
no ip address
shutdown
!
!--- This SVI (Switch Virtual Interface) is the default gateway for Users. ! interface Vlan2 description User-SVI ip address 10.1.2.1 255.255.255.0 !
!--- This SVI is the default gateway for Servers. ! interface Vlan3 description Server-SVI ip address 10.1.3.1 255.255.255.0 !
!--- This SVI is the default gateway for other L2 switches management interface. ! interface Vlan10 description Management-SVI ip address 10.1.10.1 255.255.255.0 !
!--- This route statement allows the 3850 to send Internet traffic to the Cisco router.
ip route 0.0.0.0 0.0.0.0 10.1.1.2
ip forward-protocol nd
ip http server
ip http authentication local
ip http secure-server ! ! ! line con 0 line vty 5 15 ! end
|
附註:在本範例中,所有交換器上的VLAN中繼線通訊協定(VTP)都設定為off。此交換器使用以下命令,透過全域組態模式將 VTP 設定為關閉,並建立使用者所定義的三個 VLAN:
SW_3850(config)#vtp mode off
Setting device to VTP Off mode for VLANS.
SW_3850(config)#vlan 2
SW_3850(config-vlan)#name User_VLAN
SW_3850(config-vlan)#exit
SW_3850(config)#vlan 3
SW_3850(config-vlan)#name Server_VLAN
SW_3850(config-vlan)#exit
SW_3850(config)#vlan 10
SW_3850(config-vlan)#name Mgmt_VLAN
SW_3850(config-vlan)#exit
SW_3850(config)#end
Catalyst 4500-A |
Switch-A#show running-config
Building configuration...
Current configuration : 15360 bytes
!
! Last configuration change at 01:06:17 UTC Wed Nov 16 2022
!
version 15.2
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
service internal
service compress-config
!
hostname Switch-A
!
no ip domain-lookup
no ip dhcp snooping information option
!
!
login block-for 60 attempts 3 within 60
login delay 1
login quiet-mode access-class testblock
login on-failure log
login on-success log
vtp mode off
!
!
spanning-tree mode pvst
spanning-tree extend system-id
! !
vlan 3
name Server-VLAN
!
vlan 10
name Mgmt-VLAN
!
!--- Output suppressed
!
interface GigabitEthernet1/1
shutdown
!
interface GigabitEthernet1/2
shutdown
!
interface GigabitEthernet1/3
switchport mode trunk
!
!--- Configure Server (Host-A) to be the on the access VLAN 3.
!
interface TenGigabitEthernet3/1
switchport access vlan 3
switchport mode access
!
interface TenGigabitEthernet3/2
shutdown
!
interface TenGigabitEthernet3/3
!
interface TenGigabitEthernet3/4
!
!--- Output suppressed.
!--- IP address on VLAN 10 manages this switch.
!
interface Vlan1
no ip address
!
interface Vlan10
ip address 10.1.10.2 255.255.255.0
!
ip forward-protocol nd
ip http server
ip http banner
ip http authentication local
!
!--- Configure the default gateway so that the switch is reachable from other
!--- VLANs/subnets. The gateway points to the VLAN 10 interface on the 3850.
ip default-gateway 10.1.10.1 ip forward-protocol nd
ip http server
ip http banner
ip http authentication local !
!
line con 0
stopbits 1
line vty 0 4
logging synchronous
transport input all
line vty 5 15
logging synchronous
transport input all
! end
|
Catalyst 4500-B |
Switch-B#show running-config
Building configuration...
Current configuration : 6841 bytes
!
! Last configuration change at 10:44:33 UTC Tue Nov 15 2022
!
version 15.2
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
service compress-config
!
hostname Switch-B
!
boot-start-marker
boot system bootflash:cat4500es8-universal.SPA.03.11.06.E.152-7.E6.bin
boot-end-marker
!
!
vrf definition mgmtVrf
!
address-family ipv4
exit-address-family
!
address-family ipv6
exit-address-family
!
!
no aaa new-model
hw-module module 7 mode 1
!
!
!
!
!
!
!
!
!
vtp mode off
!
!
spanning-tree mode pvst
spanning-tree extend system-id
! vlan 2 name User-VLAN ! vlan 10 name Mgmt-VLAN !
!
interface GigabitEthernet1/1
switchport mode trunk
!
interface GigabitEthernet1/2
!
interface GigabitEthernet1/3
shutdown
!
interface GigabitEthernet1/4
shutdown
!
!--- Output suppressed.
!--- Configure User (Host-B) in VLAN 2.
!
interface GigabitEthernet8/5
switchport access vlan 2
switchport mode access
!
!--- Configure the management IP address in VLAN 10.
!
interface Vlan1
no ip address
!
interface Vlan10
ip address 10.1.10.3 255.255.255.0
!
!--- Define the default route so that the switch is reachable.
!
ip default-gateway 10.1.10.1
ip forward-protocol nd
ip http server
ip http banner
ip http authentication local
!
!
line con 0
stopbits 1
line vty 0 4
login
transport input none
!
!
end
|
驗證
本節提供的資訊可讓您用來確認組態是否正常運作。
附註:有關CLI命令的詳細資訊,請參閱特定交換平台的命令參考指南。
附註:只有註冊的思科使用者有權存取這類工具以及其他內部資訊。
Catalyst 3850
SW_3850#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 : bc67.1c5d.3800
Configuration last modified by 10.0.0.10 at 0-0-00 00:00:00
Feature VLAN:
--------------
VTP Operating Mode : Off
Maximum VLANs supported locally : 1005
Number of existing VLANs : 8
Configuration Revision : 0
MD5 digest : 0x7E 0xC3 0x8D 0x91 0xC8 0x53 0x42 0x14
0x79 0xA2 0xDF 0xE9 0xC0 0x06 0x1D 0x7D
SW_3850#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Gi1/0/3 on 802.1q trunking 1
Gi1/0/5 on 802.1q trunking 1
Port Vlans allowed on trunk
Gi1/0/3 1-4094
Gi1/0/5 1-4094
Port Vlans allowed and active in management domain
Gi1/0/3 1-3,10
Gi1/0/5 1-3,10
Port Vlans in spanning tree forwarding state and not pruned
Gi1/0/3 1-3,10
Gi1/0/5 1,3,10
SW_3850#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, m - OMP
n - NAT, Ni - NAT inside, No - NAT outside, Nd - NAT DIA
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
H - NHRP, G - NHRP registered, g - NHRP registration summary
o - ODR, P - periodic downloaded static route, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is 10.100.100.2 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 10.100.100.2
10.0.0.0/8 is variably subnetted, 8 subnets, 2 masks
C 10.1.2.0/24 is directly connected, Vlan2
L 10.1.2.1/32 is directly connected, Vlan2
C 10.1.3.0/24 is directly connected, Vlan3
L 10.1.3.1/32 is directly connected, Vlan3
C 10.1.10.0/24 is directly connected, Vlan10
L 10.1.10.1/32 is directly connected, Vlan10
C 10.100.100.0/24 is directly connected, GigabitEthernet1/0/2
L 10.100.100.1/32 is directly connected, GigabitEthernet1/0/2
Catalyst 4500-A
Switch-A#show vtp status
VTP Version capable : 1 to 3
VTP version running : 2
VTP Domain Name : cisco.com
VTP Pruning Mode : Disabled
VTP Traps Generation : Disabled
Device ID : 6400.f13e.dc40
Configuration last modified by 10.1.10.2 at 0-0-00 00:00:00
Feature VLAN:
--------------
VTP Operating Mode : Off
Maximum VLANs supported locally : 1005
Number of existing VLANs : 32
Configuration Revision : 0
MD5 digest : 0x0B 0x61 0x4F 0x9B 0xCD 0x1B 0x37 0x55
0xAB 0x0C 0xC1 0x4B 0xF8 0xDE 0x33 0xB3
Switch-A#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Gi1/3 on 802.1q trunking 1
Port Vlans allowed on trunk
Gi1/3 1-4094
Port Vlans allowed and active in management domain
Gi1/3 1,3,10
Port Vlans in spanning tree forwarding state and not pruned
Gi1/3 1,3,10
Catalyst 4500-B
Switch-B#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 : 6c20.5606.3540
Configuration last modified by 10.1.10.3 at 11-15-22 10:42:29
Feature VLAN:
--------------
VTP Operating Mode : Off
Maximum VLANs supported locally : 1005
Number of existing VLANs : 7
Configuration Revision : 0
MD5 digest : 0xEC 0xB4 0x8D 0x46 0x94 0x95 0xE0 0x8F
0xEE 0x1E 0xC7 0x9F 0x26 0x88 0x49 0x9F
Switch-B#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Gi1/1 on 802.1q trunking 1
Port Vlans allowed on trunk
Gi1/1 1-4094
Port Vlans allowed and active in management domain
Gi1/1 1-2,10
Port Vlans in spanning tree forwarding state and not pruned
Gi1/1 1-2,10
疑難排解
本節內容可協助您疑難排解組態問題。
疑難排解程序
遵循以下指示:
-
如果您無法在相同的 VLAN 中偵測裝置,請檢查來源與目的地連接埠的 VLAN 指派,以確保來源與目的地都在相同的 VLAN 中。
為了檢查 VLAN 指派,請對 Cisco IOS 軟體發出 show interface status 命令。
如果來源與目的地分屬不同的交換器,請確認您已妥善設定主幹。為了檢查組態,請發出 show interfaces trunk 命令。
-
亦請檢查主幹連結兩端的原生 VLAN 是否相符。確認來源裝置與目的地裝置之間的子網路遮罩相符。
-
如果您無法偵測不同 VLAN 中的裝置,請確認您可以偵測各自的預設閘道。(請參閱步驟 1。)
此外,請確保裝置的預設網關指向正確的VLAN介面IP地址。確認子網路遮罩相符。
-
如果您無法連接至網際網路,請確認 3850 的預設路由指向正確的 IP 位址,且子網路位址與網際網路閘道路由器相符。
為了進行檢查,請發出 show ip interface interface-id 命令。確認網際網路閘道路由器已路由至網際網路與內部網路。
相關資訊