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段。
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地址。
Vxlan包轉發流程
VXLAN使用VTEP之間的無狀態隧道通過第三層傳輸網絡(IP網絡層)傳輸覆蓋層第二層網絡的通信量。
實驗拓撲
配置單播 入口複製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-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. |