N9K配置Vxlan

Vxlan是什么

VXLAN(Virtual eXtensible Local Area Network)虚拟可扩展局域网。
Vxlan是传输于跨越三层路由网络传输的第二层连接扩展。

CiscoNexus 9000交换机是为基于硬件的VXLAN功能而设计的.
它提供跨第三层边界的第二层连接扩展,
并在VXLAN和非VXLAN基础设施之间集成。
这可以在共享的公共物理基础结构上启用虚拟化和多租户数据中心的设计。

VXLAN提供了一种在第三层基础设施上扩展第二层网络的方法,
使用的是在UDP中的MAC封装和隧道。
VXLAN使用第二层扩展支持灵活的工作负载放置。
它还可以通过将租户层2层与共享传输网络分离来构建多租户数据中心。

当作为VXLAN网关部署时,Cisco Nexus 9000交换机可以连接VXLAN和经典VLAN段以创建公共转发域,
以便租户设备可以驻留在这两种环境中。

Vxlan有以下优点

VXLAN有以下优点:
•   在整个数据中心中灵活地放置多租户段。
它提供了一种在底层共享网络基础设施上扩展第二层(layer 2)的方法,以便租户工作负载可以跨数据中心的物理节点放置。
•   更高的可伸缩性,以解决更多的第二层段。
VXLAN使用24位段ID,即VXLAN网络标识符(VNID).这允许最多1600万VXLAN段在同一管理域中共存。
(相比之下,传统的VLAN使用12位段ID,最多支持4096个VLAN。)
•   基础架构中可用网络路径的利用。
VXLAN包通过底层网络根据其第3层报头进行传输。它使用等成本多径(ECMP)路由和链路聚合协议来使用所有可用路径.

Vxlan封装和数据包格式

VXLAN是第三层网络上的第二层覆盖方案。它使用MAC地址在用户数据报协议(MAC-in-UDP)封装提供了一种方法,
以扩展第二层段跨越数据中心网络。VXLAN是一种解决方案,可以在共享的公共物理基础设施上支持灵活的、
大规模的多租户环境。物理数据中心网络上的传输协议是IP+UDP。

VXLAN定义了一种MAC in UDP封装方案,其中原始的第二层帧中添加了一个VXLAN报头,
然后将其放置在UDP-IP数据包中。通过这种在UDP中的MAC封装,VXLAN在第三层网络上穿越了第二层网络.

VXLAN使用一个8字节的VXLAN头,它由一个24位的VNID和几个保留位组成。
VXLAN报头和原始以太网帧一起进入UDP有效负载。24位VNID用于识别第二层段和保持第二层段之间的隔离。
由于VNID中有24位,VXLAN可以支持1600万个LAN段。

N9K配置Vxlan

Vxlan隧道端点 VTEP

VTEP(Vxlan Tunnel End Point)vxlan虚拟隧道端点。

VXLAN使用VXLAN隧道端点(VTEP)设备将租户的终端设备映射到VXLAN段,
并执行VXLAN封装和解封装。每个VTEP功能都有两个接口:
一个是本地局域网段上的交换机接口,通过桥接支持本地端点通信;另一个是传输IP网络的IP接口。

IP接口具有唯一的IP地址,用于标识传输IP网络上的VTEP设备,称为基础设施VLAN。
VTEP设备使用此IP地址封装以太网帧,并通过IP接口将封装的数据包发送到传输网络。
VTEP设备还发现其VXLAN段的远程VTEP,并通过其IP接口学习远程MAC地址到VTEP的映射。

VXLAN段独立于底层网络拓扑;相反,VTEP之间的底层IP网络独立于VXLAN覆盖。
它基于外部IP地址报头对封装的数据包进行路由,其中以起始的VTEP作为源IP地址,
以终止的VTEP作为目标IP地址。

N9K配置Vxlan

Vxlan包转发流程

VXLAN使用VTEP之间的无状态隧道通过第三层传输网络(IP网络层)传输覆盖层第二层网络的通信量。

实验拓扑

N9K配置Vxlan

配置单播 入口复制Vxlan

配置N9K-1

#激活ospf
N9K-1(config)# feature ospf 
#启动ospf
N9K-1(config)# router ospf 1 
N9K-1(config-router)# router-id 2.2.2.1
N9K-1(config-router)# exit
#配置loopback接口,并宣告路由
N9K-1(config)# interface loopback 0 
N9K-1(config-if)# ip add 2.2.2.1 255.255.255.255
N9K-1(config-if)# ip router ospf 1 area 0 
N9K-1(config-if)# exit
#配置e1/1接口ip,并宣告ospf路由
N9K-1(config)# interface ethernet 1/1
N9K-1(config-if)# no switchport 
N9K-1(config-if)# ip add 1.1.1.1 255.255.255.0
N9K-1(config-if)# ip router ospf 1 area 0 
N9K-1(config-if)# no shutdown 
N9K-1(config-if)# exit

#启用vxlan
N9K-1(config)# feature nv overlay 
#全局启动vxlan桥域
N9K-1(config)# feature vn-segment-vlan-based 

#配置下联host1接口
N9K-1(config)# interface ethernet 1/2
N9K-1(config-if)# switchport 
N9K-1(config-if)# switchport mode access 
N9K-1(config-if)# switchport access vlan 11 
N9K-1(config-if)# no shutdown 
N9K-1(config-if)# exit

#设置vlan11
N9K-1(config)# vlan 11
#配置vxlan vnid
N9K-1(config-vlan)# vn-segment 10011 
N9K-1(config-vlan)# exit

#创建Vxlan nve接口
#用于传输vxlan隧道
N9K-1(config)# interface nve 1 
#启动接口
N9K-1(config-if-nve)# no shutdown 
#配置用于去和对端互联的接口,且cisco要求必须是loopback接口。
N9K-1(config-if-nve)# source-interface loopback 0 
#绑定nve接口和vni,可以绑定多个。
N9K-1(config-if-nve)# member vni 10011 
#激活static ingress replication for the VNI
N9K-1(config-if-nve-vni)# ingress-replication protocol static 
#配置Vxlan peer,ip最好是对端loopback接口
N9K-1(config-if-nve-vni-ingr-rep)# peer-ip 2.2.2.3 
N9K-1(config-if-nve-vni-ingr-rep)# exit
N9K-1(config-if-nve-vni)# exit
N9K-1(config-if-nve)# exit

#查看vxlan nve接口状态
N9K-1(config)# sh nve vni ingress-replication 
Interface VNI      Replication List  Source  Up Time      
--------- -------- ----------------- ------- -------      

nve1      10011    2.2.2.3           CLI     Down 

配置N9K-2

#激活ospf
N9K-2(config)# feature ospf
#启动ospf
N9K-2(config)# router ospf 1 
N9K-2(config-router)# router-id 2.2.2.3
N9K-2(config-router)# exit
#配置loopback接口,并宣告路由
N9K-2(config)# interface loopback 0 
N9K-2(config-if)# ip add 2.2.2.3 255.255.255.255
N9K-2(config-if)# ip router ospf 1 area 0 
N9K-2(config-if)# exit
#配置e1/1接口ip,并宣告ospf路由
N9K-2(config)# interface ethernet 1/1
N9K-2(config-if)# no switchport 
N9K-2(config-if)# ip add 2.1.1.1 255.255.255.0
N9K-2(config-if)# ip router ospf 1 area 0 
N9K-2(config-if)# no shutdown 
N9K-2(config-if)# exit

#启用vxlan
N9K-2(config)# feature nv overlay 
#全局启动vxlan桥域
N9K-2(config)# feature vn-segment-vlan-based 

#配置下联host1接口
N9K-2(config)# interface ethernet 1/2
N9K-2(config-if)# switchport 
N9K-2(config-if)# switchport mode access 
N9K-2(config-if)# switchport access vlan 11
N9K-2(config-if)# no shutdown 
N9K-2(config-if)# exit

#设置vlan11
N9K-2(config)# vlan 11
#配置vxlan vnid
N9K-2(config-vlan)# vn-segment 10011 
N9K-2(config-vlan)# exit

#创建Vxlan nve接口
#用于传输vxlan隧道
N9K-2(config)# interface nve 1 
#启动接口
N9K-2(config-if-nve)# no shutdown 
#配置用于去和对端互联的接口,且cisco要求必须是loopback接口。
N9K-2(config-if-nve)# source-interface loopback 0 
#绑定nve接口和vni,可以绑定多个。
N9K-2(config-if-nve)# member vni 10011 
#激活static ingress replication for the VNI
N9K-2(config-if-nve-vni)# ingress-replication protocol static 
#配置Vxlan peer,ip最好是对端loopback接口
N9K-2(config-if-nve-vni-ingr-rep)# peer-ip 2.2.2.3 
N9K-2(config-if-nve-vni-ingr-rep)# exit
N9K-2(config-if-nve-vni)# exit
N9K-2(config-if-nve)# exit

#查看vxlan nve接口状态
N9K-2(config)# sh nve vni ingress-replication 
Interface VNI      Replication List  Source  Up Time      
--------- -------- ----------------- ------- -------      

nve1      10011    2.2.2.1           CLI     Down 

配置R3

R3(config)#interface loopback 0
R3(config-if)#ip add 2.2.2.2 255.255.255.255
R3(config-if)#no shutdown 
R3(config-if)#exit

R3(config)#interface ethernet 0/0
R3(config-if)#no switchport 
R3(config-if)#ip add 1.1.1.2 255.255.255.0
R3(config-if)#no shutdown 
R3(config-if)#exit

R3(config)#interface ethernet 0/1
R3(config-if)#no swi
R3(config-if)#ip add 2.1.1.2 255.255.255.0
R3(config-if)#no shutdown 
R3(config-if)#exit

R3(config)#router ospf 1 
R3(config-router)#router-id 2.2.2.2
R3(config-router)#network 2.2.2.2 0.0.0.0 area 0 
R3(config-router)#network 1.1.1.0 0.0.0.255 area 0 
R3(config-router)#network 2.1.1.0 0.0.0.255 area 0 
R3(config-router)#exit

配置两个hosts

VPCS> set pcname host1

host1> ip 11.1.1.1/24
Checking for duplicate address...
PC1 : 11.1.1.1 255.255.255.0
VPCS> set pcname host2

host2> ip 11.1.1.2/24
Checking for duplicate address...
PC1 : 11.1.1.2 255.255.255.0

验证

查看ospf邻居

R3#sh ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.3           1   FULL/DR         00:00:38    2.1.1.1         Ethernet0/1
2.2.2.1           1   FULL/DR         00:00:31    1.1.1.1         Ethernet0/0

查看vxlan nve接口状态:

N9K-1(config)# sh nve vni ingress-replication 
Interface VNI      Replication List  Source  Up Time      
--------- -------- ----------------- ------- -------      

nve1      10011    2.2.2.3           CLI     00:11:16 
N9K-2(config)# sh nve vni ingress-replication 
Interface VNI      Replication List  Source  Up Time      
--------- -------- ----------------- ------- -------      

nve1      10011    2.2.2.1           CLI     00:11:35

从host1pinghost2:

host1> ping 11.1.1.2

84 bytes from 11.1.1.2 icmp_seq=1 ttl=64 time=47.067 ms
84 bytes from 11.1.1.2 icmp_seq=2 ttl=64 time=31.118 ms
84 bytes from 11.1.1.2 icmp_seq=3 ttl=64 time=28.959 ms
84 bytes from 11.1.1.2 icmp_seq=4 ttl=64 time=15.407 ms
84 bytes from 11.1.1.2 icmp_seq=5 ttl=64 time=23.401 ms

查看Vxlan vni状态

N9K-1# sh nve vni 10011 
Codes: CP - Control Plane        DP - Data Plane          
       UC - Unconfigured         SA - Suppress ARP

Interface VNI      Multicast-group   State Mode Type [BD/VRF]      Flags
--------- -------- ----------------- ----- ---- ------------------ -----
nve1      10011    UnicastStatic     Up    DP   L2 [11]   

配置基于组播Vxlan

网络拓扑

N9K配置Vxlan

配置N9K-1

#激活组播pim
N9K-1(config)# feature pim
#配置处理组播的路由处理器地址
N9K-1(config)# ip pim rp-address 10.10.10.10 group-list 224.0.0.0/4

##route processor (RP)路由处理器

#激活ospf
N9K-1(config)# feature ospf 
#启动ospf
N9K-1(config)# router ospf 1 
N9K-1(config-router)# router-id 2.2.2.1
N9K-1(config-router)# exit
#配置loopback接口,并宣告路由
N9K-1(config)# interface loopback 0 
N9K-1(config-if)# ip add 2.2.2.1 255.255.255.255
N9K-1(config-if)# ip router ospf 1 area 0 
#接口启用pim
N9K-1(config-if)# ip pim sparse-mode 
N9K-1(config-if)# exit
#配置e1/1接口ip,并宣告ospf路由
N9K-1(config)# interface ethernet 1/1
N9K-1(config-if)# no switchport 
N9K-1(config-if)# ip add 1.1.1.1 255.255.255.0
N9K-1(config-if)# ip router ospf 1 area 0 
N9K-1(config-if)# ip pim sparse-mode 
N9K-1(config-if)# no shutdown 
N9K-1(config-if)# exit

#启用vxlan
N9K-1(config)# feature nv overlay 
#全局启动vxlan桥域
N9K-1(config)# feature vn-segment-vlan-based 

#配置下联host1接口
N9K-1(config)# interface ethernet 1/2
N9K-1(config-if)# switchport 
N9K-1(config-if)# switchport mode access 
N9K-1(config-if)# switchport access vlan 11 
N9K-1(config-if)# no shutdown 
N9K-1(config-if)# exit

#设置vlan11
N9K-1(config)# vlan 11
#配置vxlan vnid
N9K-1(config-vlan)# vn-segment 10011 
N9K-1(config-vlan)# exit

#创建Vxlan nve接口
#用于传输vxlan隧道
N9K-1(config)# interface nve 1 
#启动接口
N9K-1(config-if-nve)# no shutdown 
#配置用于去和对端互联的接口,且cisco要求必须是loopback接口。
N9K-1(config-if-nve)# source-interface loopback 0 
#绑定nve接口和vni,可以绑定多个。
N9K-1(config-if-nve)# member vni 10011 
#配置VNI组播地址
N9K-1(config-if-nve)# member vni 10011 mcast-group 230.1.1.1
N9K-1(config-if-nve)# exit

#查看vxlan nve接口状态
N9K-1(config)# sh nve vni 
Codes: CP - Control Plane        DP - Data Plane          
       UC - Unconfigured         SA - Suppress ARP

Interface VNI      Multicast-group   State Mode Type [BD/VRF]      Flags
--------- -------- ----------------- ----- ---- ------------------ -----
nve1      10011    230.1.1.1         Up    DP   L2 [11] 

配置N9K-2

#激活组播pim
N9K-2(config)# feature pim
#配置处理组播的路由处理器地址
N9K-2(config)# ip pim rp-address 10.10.10.10 group-list 224.0.0.0/4

##route processor (RP)路由处理器

#激活ospf
N9K-2(config)# feature ospf 
#启动ospf
N9K-2(config)# router ospf 1 
N9K-2(config-router)# router-id 2.2.2.3
N9K-2(config-router)# exit
#配置loopback接口,并宣告路由
N9K-2(config)# interface loopback 0 
N9K-2(config-if)# ip add 2.2.2.3 255.255.255.255
N9K-2(config-if)# ip router ospf 1 area 0 
#接口启用pim
N9K-2(config-if)# ip pim sparse-mode 
N9K-2(config-if)# exit
#配置e1/1接口ip,并宣告ospf路由
N9K-2(config)# interface ethernet 1/1
N9K-2(config-if)# no switchport 
N9K-2(config-if)# ip add 2.1.1.1 255.255.255.0
N9K-2(config-if)# ip router ospf 1 area 0 
N9K-2(config-if)# ip pim sparse-mode 
N9K-2(config-if)# no shutdown 
N9K-2(config-if)# exit

#启用vxlan
N9K-2(config)# feature nv overlay 
#全局启动vxlan桥域
N9K-2(config)# feature vn-segment-vlan-based 

#配置下联host1接口
N9K-2(config)# interface ethernet 1/2
N9K-2(config-if)# switchport 
N9K-2(config-if)# switchport mode access 
N9K-2(config-if)# switchport access vlan 11 
N9K-2(config-if)# no shutdown 
N9K-2(config-if)# exit

#设置vlan11
N9K-2(config)# vlan 11
#配置vxlan vnid
N9K-2(config-vlan)# vn-segment 10011 
N9K-2(config-vlan)# exit

#创建Vxlan nve接口
#用于传输vxlan隧道
N9K-2(config)# interface nve 1 
#启动接口
N9K-2(config-if-nve)# no shutdown 
#配置用于去和对端互联的接口,且cisco要求必须是loopback接口。
N9K-2(config-if-nve)# source-interface loopback 0 
#绑定nve接口和vni,可以绑定多个。
N9K-2(config-if-nve)# member vni 10011 
#配置VNI组播地址
N9K-2(config-if-nve)# member vni 10011 mcast-group 230.1.1.1
N9K-2(config-if-nve)# exit

#查看vxlan nve接口状态
N9K-2# sh nve vni 
Codes: CP - Control Plane        DP - Data Plane          
       UC - Unconfigured         SA - Suppress ARP

Interface VNI      Multicast-group   State Mode Type [BD/VRF]      Flags
--------- -------- ----------------- ----- ---- ------------------ -----
nve1      10011    230.1.1.1         Up    DP   L2 [11]  

注意:

这时候看NVE 1接口是已经up了,但是外部中间设备R3并没有配置组播转发,所以vxlan还没有完成。

配置R3

#激活组播
R3(config)#ip multicast-routing

R3(config)#interface loopback 0
R3(config-if)#ip add 2.2.2.2 255.255.255.255
R3(config-if)#ip pim sparse-mode 
R3(config-if)#no shutdown 
R3(config-if)#exit

R3(config)#interface ethernet 0/0
R3(config-if)#no switchport 
R3(config-if)#ip add 1.1.1.2 255.255.255.0
R3(config-if)#ip pim sparse-mode 
R3(config-if)#no shutdown 
R3(config-if)#exit

R3(config)#interface ethernet 0/1
R3(config-if)#no swi
R3(config-if)#ip add 2.1.1.2 255.255.255.0
R3(config-if)#ip pim sparse-mode 
R3(config-if)#no shutdown 
R3(config-if)#exit

R3(config)#router ospf 1 
R3(config-router)#router-id 2.2.2.2
R3(config-router)#network 2.2.2.2 0.0.0.0 area 0 
R3(config-router)#network 1.1.1.0 0.0.0.255 area 0 
R3(config-router)#network 2.1.1.0 0.0.0.255 area 0 
R3(config-router)#exit

#指定组播rp-address
ip pim rp-address 2.2.2.2

验证

查看nve接口状态:

N9K-1# sh nve vni 
Codes: CP - Control Plane        DP - Data Plane          
       UC - Unconfigured         SA - Suppress ARP

Interface VNI      Multicast-group   State Mode Type [BD/VRF]      Flags
--------- -------- ----------------- ----- ---- ------------------ -----
nve1      10011    230.1.1.1         Up    DP   L2 [11]   

查看nve对端设备:

N9K-1# sh nve peers 
Interface Peer-IP          State LearnType Uptime   Router-Mac       
--------- ---------------  ----- --------- -------- -----------------
nve1      2.2.2.3          Up    DP        00:10:13 n/a          
N9K-1# sh nve peers detail 
Details of nve Peers:
----------------------------------------
Peer-Ip: 2.2.2.3
    NVE Interface       : nve1
    Peer State          : Up
    Peer Uptime         : 00:11:28
    Router-Mac          : n/a
    Peer First VNI      : 10011
    Time since Create   : 00:13:03
    Configured VNIs     : 10011
    Provision State     : add-complete
    Route-Update        : Yes
    Peer Flags          : None
    Learnt CP VNIs      : --
    Peer-ifindex-resp   : Yes
----------------------------------------

Host1 ping Host2:

host1> sh ip 

NAME        : host1[1]
IP/MASK     : 11.1.1.1/24
GATEWAY     : 0.0.0.0
DNS         : 
MAC         : 00:50:79:66:68:04
LPORT       : 20000
RHOST:PORT  : 127.0.0.1:30000
MTU         : 1500

host1> ping 11.1.1.2

84 bytes from 11.1.1.2 icmp_seq=1 ttl=64 time=16.761 ms
84 bytes from 11.1.1.2 icmp_seq=2 ttl=64 time=23.309 ms
84 bytes from 11.1.1.2 icmp_seq=3 ttl=64 time=33.010 ms
84 bytes from 11.1.1.2 icmp_seq=4 ttl=64 time=27.178 ms
84 bytes from 11.1.1.2 icmp_seq=5 ttl=64 time=40.473 ms

验证VXLAN 其他方式配置

To display the VXLAN configuration information, enter one of the following commands:

Command Purpose
show tech-support vxlan [platform ] Displays related VXLAN tech-support information.
show logging level nve Displays logging level.
show tech-support nve Displays related NVE tech-support information.
show run interface nve x Displays NVE overlay interface configuration.
show nve interface Displays NVE overlay interface status.
show nve peers Displays NVE peer status.
show nve peers peer_IP_address interfaceinterface_ID counters Displays per NVE peer statistics.
clear nve peers peer_IP_address interfaceinterface_ID counters Clears per NVE peer statistics.
clear nve peer-ip peer-ip-address Clears stale NVE peers. Stale NVE peers are peers that do not have MAC addresses learnt behind them.
show nve vni Displays VXLAN VNI status.
show nve vni ingress-replication Displays the mapping of VNI to ingress-replication peer list and uptime for each peer.
show nve vni vni_number counters Displays per VNI statistics.
clear nve vni vni_number counters Clears per VNI statistics.
show nve vxlan-params Displays VXLAN parameters, such as VXLAN destination or UDP port.
Command Purpose
show tech-support vxlan [platform ] Displays related VXLAN tech-support information.
show interface {ethernet slot/port \ port-channel port} vlan mapping Displays VLAN mapping information for a specific interface or port channel.
show logging level nve Displays logging level.
show tech-support nve Displays related NVE tech-support information.
show run interface nve x Displays NVE overlay interface configuration.
show nve interface Displays NVE overlay interface status.
show nve peers Displays NVE peer status.
show nve peers peer_IP_address interfaceinterface_ID counters Displays per NVE peer statistics.
clear nve peers peer_IP_address interfaceinterface_ID counters Clears per NVE peer statistics.
clear nve peer-ip peer-ip-address Clears stale NVE peers. Stale NVE peers are peers that do not have MAC addresses learnt behind them.
show nve vni Displays VXLAN VNI status.
show nve vni ingress-replication Displays the mapping of VNI to ingress-replication peer list and uptime for each peer.
show nve vni vni_number counters Displays per VNI statistics.
clear nve vni vni_number counters Clears per VNI statistics.
show nve vxlan-params Displays VXLAN parameters, such as VXLAN destination or UDP port.
show mac address-table static interface nve 1 Displays static MAC information.
show vxlan interface Displays VXLAN interface status for 9200 platform switches. .
show vxlan interface \ count Displays VXLAN VLAN logical port VP count.
Command Purpose
show run track Displays tracking information for running-config.
show track Displays tracking information for IP prefix for an endpoint.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章