vPC是一种实现跨设备链路聚合的机制,基于LACP进行了扩展,能够实现多台设备间的链路聚合,从而把链路可靠性从单设备级提高到了多设备级。目前,vPC可以在Cisco Nexus 9000、7000、5000和3000系列平台上实施。

Cisco Nexus VPC配置_Cisco Nexus 9000

名词
  • VPC - Virtual Port Channel
  • VPC Peer - 指的是通过vPC Peer-link链接的两台相邻交换机,其它设备通过Multi-Channel Ethernet (MEC)跟这两台交换机链接。
  • VPC Peer-link - 用于同步和转发两台VPC PEER的数据,包括组播,广播,单播等。需要至少10G以上的端口链接。
  • VPC Peer Keepalive Link - 提供一个L3通道来再次验证两个VPC PEER是否运作正常。可以检测出VPC Peer自己是否发生故障或者对方已经关闭。它不转发和同步数据,使用UDP 3200端口,默认检测时间为1秒超时5秒。
  • VPC domain - 通过domain ID来区分不同domain。
  • VPC Member port - 加入VPC Peer-link的端口。
  • Cisco Fabric Service (CFS) - 该协议用于有状态的同步和配置,不需要进行额外的配置。
vPC配置步骤

vPC配置通常有9个步骤,应该注意的是,vPC 配置的顺序很重要,基本的 vPC 设置是通过使用前 4 个步骤建立的:

Cisco Nexus VPC配置_Cisco Nexus 7000_02

步骤 1:开启vPC特性并在两台 Nexus 交换机上配置 vPC domain ID。

步骤 2:选择一个Peer Keepalive链接部署方式。

步骤 3:建立vPC Peer Keepalive链接。

步骤 4:配置vPC Peer-Link,完成全局 vPC 配置。

步骤 5:将vPC配置到下游交换机或设备。

步骤 6:(可选)开启peer gateway以优化HSRP。

步骤 7:(可选)开启peer switch特性来优化vPC的STP。

步骤 8:(可选)其它优化VPC设定。

步骤 9:(可选)验证vPC参数。

CISCO NEXUS VPC 配置示例

这里我们以两台N5K交换机为例来配置vPC。两台交换机分别命名为N5k-Primary和N5k-Secondary。

步骤 1:开启vPC特性并在两台 Nexus 交换机上配置 vPC domain ID。
N5k-Primary(config)# feature vpc
N5k-Primary(config)# vpc domain 1
N5k-Primary(config-vpc-domain)# show vpc role
vPC Role status
----------------------------------------------------
vPC role                        : none established             
Dual Active Detection Status    : 0
vPC system-mac                  : 00:23:04:ee:be:01             
vPC system-priority             : 32667
vPC local system-mac            : 8c:60:4f:2c:b3:01            
vPC local role-priority         : 0
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
N5k-Secondary(config)# feature vpc
N5k-Secondary(config)# vpc domain 1
N5k-Secondary(config-vpc-domain)# show vpc role
vPC Role status
----------------------------------------------------
vPC role                                    : none established             
Dual Active Detection Status    : 0
vPC system-mac                  : 00:23:04:ee:be:01            
vPC system-priority             : 32667
vPC local system-mac            : 8c:60:4f:aa:c2:3c            
vPC local role-priority         : 0
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

两台交换机必须使用相同的domain ID,这里把domain ID配置为1。show vpc role命令的显示的系统MAC地址来自vPC的domain ID,它等于01。

步骤 2:选择一个Peer Keepalive链接部署方式。

Peer Keepalive有如下部署方式:

Cisco Nexus VPC配置_Cisco Nexus 9000_03

这里我们采用第二种方式启用SVI进行。先启用一个专用VLAN,然后配置SVI并划分到一个专用VRF里面来区分和隔离其它流量。默认情况下,vPC Peer Keepalive数据包使用管理接口并在VRF management中传输。但是强烈建议为vPC Peer Keepalive链路单独配置一个VRF,以确保Peer Keepalive流量始终在Peer Keepalive链路上传输,而从不在Peer-Link上传输。

这里我们使用接口Ethernet1/32用作Peer Keepalive的专用接口:

N5k-Primary(config)# vlan 23
N5k-Primary(config-vlan)# name keepalive
N5k-Primary(config)# vrf context keepalive

N5k-Primary(config)#interface Vlan23
N5k-Primary(config)#  vrf member keepalive
N5k-Primary(config)#  ip address 192.168.1.1/24

N5k-Primary(config)#interface Ethernet1/32
 N5k-Primary(config)# switchport access vlan 23
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
N5k-Secondary (config)# vlan 23
N5k-Secondary(config-vlan)# name keepalive
N5k-Secondary(config)# vrf context keepalive

N5k-Secondary (config)# interface Vlan23
N5k-Secondary (config)#   vrf member keepalive
N5k-Secondary (config)#  ip address 192.168.1.2/24

N5k-Secondary (config)# interface Ethernet1/32
N5k-Secondary (config)#  switchport access vlan 23
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

验证peer keepalive链接:

N5k-Secondary# ping 192.168.1.1 vrf keepalive
PING 192.168.1.1 (192.168.1.1): 56 data bytes
36 bytes from 192.168.1.2: Destination Host Unreachable
Request 0 timed out
64 bytes from 192.168.1.1: icmp_seq=1 ttl=254 time=3.91 ms
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

前几个包丢包是正常现象,因为交换机需要首先发出 ARP 请求以获取192.168.1.1的MAC地址,然后发送 ICMP数据包。

步骤 3:建立vPC Peer Keepalive链接。
N5k-Primary(config)# vpc domain 1
N5k-Primary (config-vpc-domain)# peer-keepalive destination 192.168.1.2 source 192.168.1.1 vrf keepalive
  • 1.
  • 2.
N5k-Secondary(config)# vpc domain 1
N5k-Secondary(config-vpc-domain)# peer-keepalive destination 192.168.1.1 source 192.168.1.2 vrf keepalive
  • 1.
  • 2.

在两台交换机上使用show vpc peer-keepalive命令验证:

N5k-Secondary# show vpc peer-keepalive
vPC keep-alive status           : peer is alive                
--Peer is alive for             : (106) seconds, (385) msec
--Send status                   : Success
--Last send at                  : 2017.06.22 22:46:32 106 ms
--Sent on interface             : Vlan23
--Receive status                : Success
--Last receive at               : 2017.06.22 22:46:32 5 ms
--Received on interface         : Vlan23
--Last update from peer         : (0) seconds, (333) msec

vPC Keep-alive parameters
--Destination                   : 192.168.1.1
--Keepalive interval            : 1000 msec
--Keepalive timeout             : 5 seconds
--Keepalive hold timeout        : 3 seconds
--Keepalive vrf                 : keepalive
--Keepalive udp port            : 3200
--Keepalive tos                 : 192
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
步骤 4:配置vPC Peer-Link,完成全局 vPC 配置。

开启lacp特性,并建立PortChannel用于vPC Peer-Link。

N5k-Primary (config)# feature lacp
N5k-Primary(config)# interface ethernet 1/2-3
N5k-Primary(config-if-range)# description *** VPC PEER LINKS ***
N5k-Primary(config-if-range)# channel-group 23 mode active
N5k-Primary(config)# interface port-channel 23
N5k-Primary(config-if)# description *** VPC PEER LINKS ***
N5k-Primary(config-if)# switchport mode trunk
N5k-Primary(config-if)# switchport trunk allowed vlan 10, x, xx, xxx
N5k-Primary(config-if)# vpc peer-link
N5k-Primary(config-if)# spanning-tree port type network
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

把PortChannel配置成Trunk,并允许相关Vlan流量。建议排除Peer Keepalive VLAN,如上面配置的Vlan 23,同时不建议在该Trunk上允许non-vPC VLAN,因为这种配置可能会导致当vPC出现问题时non-vPC VLAN的流量中断,如果VPC同行链接失败。

N5k-Secondary(config)# feature lacp
N5k-Seondary(config)# interface ethernet 1/2-3
N5k-Secondary(config-if-range)# description *** VPC PEER LINKS ***
N5k-Secondary(config-if-range)# channel-group 23 mode active
N5k-Secondary(config)# interface port-channel 23
N5k-Secondary(config-if)# description *** VPC PEER LINKS ***
N5k-Secondary(config-if)# switchport mode trunk
N5k-Secondary(config-if)# switchport trunk allowed vlan 10, x, xx, xxx
N5k-Secondary(config-if)# vpc peer-link
N5k-Secondary(config-if)# spanning-tree port type network
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

在两台交换机上使用show vpc验证:

N5k-Secondary# show vpc
Legend:
                (*) - local vPC is down, forwarding via vPC peer-link
vPC domain id                     : 1  
Peer status                       : peer adjacency formed ok     
vPC keep-alive status             : peer is alive                
Configuration consistency status  : success
Per-vlan consistency status       : success                      
Type-2 consistency status         : success
vPC role                          : secondary, operational primary
Number of vPCs configured         : 0  
Peer Gateway                      : Disabled
Dual-active excluded VLANs        : -
Graceful Consistency Check        : Enabled
Auto-recovery status              : Enabled (timeout = 240 seconds)
vPC Peer-link status
---------------------------------------------------------------------
id   Port   Status Active vlans   
--   ----   ------ --------------------------------------------------
1    Po23   up     10
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
步骤 5:将vPC配置到下游交换机或设备。

上述步骤中已正确建立vPC域,因此现在可以为下游交换机配置vPC。这台下游交换机将分别连接到两台vPC Peer交换机,以增加冗余和带宽可用性。

Cisco Nexus VPC配置_Cisco Nexus 3000_04

N5k-Primary(config)#interface Ethernet1/1
N5k-Primary(config)#  description *** Connected to Switch ***
N5k-Primary(config)#  switchport access vlan 10
N5k-Primary(config)#  channel-group 10

N5k-Primary(config)#interface port-channel10
N5k-Primary(config)# switchport access vlan 10
N5k-Primary(config)#  vpc 10
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
N5k-Secondary(config)#interface Ethernet1/1
N5k-Secondary(config)#  description *** Connected to Switch ***
N5k-Secondary(config)#  switchport access vlan 10
N5k-Secondary(config)#  channel-group 10

N5k-Secondary(config)#interface port-channel10
N5k-Secondary(config)# switchport access vlan 10
N5k-Secondary(config)#  vpc 10
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
Switch(config)#interface range Ethernet1/1 - 2
Switch(config)#description *** Connected to vPC Peer ***
Switch(config)#switchport access vlan 10
Switch(config)#  channel-group 10

Switch(config)#interface port-channel10
Switch(config)# switchport access vlan 10
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
步骤 6:(可选)开启peer gateway以优化HSRP。

在vPC中使用HSRP没有任何特殊配置,同正常的HSRP操作一样,Active HSRP接口响应ARP请求,区别的是vPC HSRP(active 和 standby)均会转发流量。
如果发送到3层网关的帧使用MAC burn -in-address(实mac)而不是HSRP MAC(虚mac)地址,那么因PortChannel hash可能会将它转发到错误的vPC peer,而该错误的vPC peer将会通过vPC peer link将帧发给另一个vPC peer。这样因为 vPC duplicate prevention rule,帧将不会再给vPC成员端口。解决以上问题的配置命令:peer-gateway。该命令允许vPC peers 交换各自的BIA MAC地址的信息,这样它们就可以在本地直接转发流量,而不必通过vPC peer link转发流量。

N5k-Primary(config)# vpc domain 1
N5k-Primary(config-vpc-domain)# peer-gateway
  • 1.
  • 2.
N5k-Secondary(config)# vpc domain 1
N5k-Secondary(config-vpc-domain)# peer-gateway
  • 1.
  • 2.
步骤 7:(可选)开启peer switch特性来优化vPC的STP。

通常情况下,我们需要将Primary Switch配置成root primary,将Secondary Switch配置成此root secondary。开启peer switch特性后可以使两台vPC交换机运行为单个生成树根。加快了vPC交换机出现故障时STP的收敛速度。

N5k-Primary(config)# vpc domain 1
N5k-Primary(config-vpc-domain)# peer-switch
  • 1.
  • 2.
N5k-Secondary(config)# vpc domain 1
N5k-Secondary(config-vpc-domain)# peer-switch
  • 1.
  • 2.
步骤 8:(可选)其它优化VPC设定。
N5k-Primary(config)# vpc domain 1
N5k-Primary(config-vpc-domain)# delay restore 360
N5k-Primary(config-vpc-domain)# auto-recovery
Warning: Enables restoring of vPCs in a peer-detached state after reload, will wait for 240 seconds to determine if peer is un-reachable
N5k-Primary(config-vpc-domain)# graceful consistency-check
N5k-Primary(config-vpc-domain)# ip arp synchronize
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
N5k-Secondary(config)# vpc domain 1
N5k-Secondary(config-vpc-domain)# delay restore 360
N5k-Secondary(config-vpc-domain)# auto-recovery
Warning: Enables restoring of vPCs in a peer-detached state after reload, will wait for 240 seconds to determine if peer is un-reachable
N5k-Secondary(config-vpc-domain)# graceful consistency-check
N5k-Secondary(config-vpc-domain)# ip arp synchronize
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
步骤 9:(可选)验证vPC参数。
N5k-Primary# show vpc brief
N5k-Primary# show vpc consistency-parameters global
  • 1.
  • 2.