盛科交换机和ovs交换机建立VxLAN隧道

环境信息

盛科交换机信息:

R3# show version 
CentecOS Software, E580, Version 5.3.6
Copyright (C) 2004-2017 Centec Networks Inc. All rights reserved.
The current running image is: flash:/boot/centecOS-v580-openflow-v5.3.6.bin

R3 uptime is 2 days, 22 hours, 56 minutes
Hardware Type        : 32X
SDRAM size           : 1024M
Flash size           : 2048M
Hardware Version     : 2.0
EPLD Version         : 1.2
BootRom Version      : 8.1.1
System serial number : E142GD169030

ovs交换机信息:

root@openlab:~# cat /etc/issue
Ubuntu 18.04.5 LTS 
 l

root@openlab:~# ovs-vsctl --version
ovs-vsctl (Open vSwitch) 2.6.3
DB Schema 7.14.0

网络拓扑

miniet新建拓扑

使用mininet创建最简单拓扑

mn

网卡信息

盛科交换机配置

设置local_ip

R3# configure terminal 
R3(config)# openflow tunnel local_vtep_ip 172.171.3.104

创建vxlan隧道

ovs-vsctl add-port br0 vxlan1 -- set interface vxlan1 type=vxlan options:remote_ip=172.171.8.21 options:bind_port=eth-0-1  options:nexthop_mac=64:00:6a:1f:d5:9f

盛科v580的vxlan隧道必须有三个配置项:
remote_ip: 隧道另一端的地址,这里是ovs交换机所在主机的网卡ip,enp3s0的ip。
bind_port: 隧道绑定的端口。vxlan隧道是虚拟出来的端口,物理交换机上不存在,所以需要一个物理端口承载流量。这里是交换机出流量的端口eth-0-1。
nexthop_mac: remote_ip 配置的网卡的mac地址,就是enp3s0的mac地址。
隧道:

隧道的端口:

下发流表

ovs-ofctl add-flow br0 "in_port=5,actions=set_field:10->tun_id,output:2201"
ovs-ofctl add-flow br0 "in_port=2201,tun_id=10,actions=output:5"

进隧道流量
主机连接到盛科交换机5端口,将所有5端口进来的流量设置tun_id为10,然后转发到vxlan隧道的端口2201
进隧道流量
隧道对端过来的流量从2201端口进入交换机。匹配进端口为2201,tun_id=10的流量,转发到5端口中

ovs交换机配置

新建隧道

ovs-vsctl add-port s1 vtep -- set interface vtep type=vxlan option:remote_ip=172.171.3.104  option:key=flow ofport_request=10

ovs交换机的两个参数:
remote_ip: 隧道另一端的ip地址。这里要写盛科交换机的local_ip
key=flow ofport_request: vxlan类型为基于流表,新建的端口为10

root@openlab:~# ovs-vsctl show 
a3e32c7e-3d35-40ac-b360-15603a98a1ec
    Bridge "s1"
        Controller "tcp:127.0.0.1:6653"
            is_connected: true
        Controller "ptcp:6654"
        fail_mode: secure
        Port "s1-eth2"
            Interface "s1-eth2"
        Port "s1"
            Interface "s1"
                type: internal
        Port "s1-eth1"
            Interface "s1-eth1"
        Port vtep
            Interface vtep
                type: vxlan
                options: {key=flow, remote_ip="172.171.3.104"}
    ovs_version: "2.6.3"
root@openlab:~# ovs-ofctl show s1
OFPT_FEATURES_REPLY (xid=0x2): dpid:0000000000000001
n_tables:254, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
 1(s1-eth1): addr:1a:a3:c9:a7:f1:ec
     config:     0
     state:      0
     current:    10GB-FD COPPER
     speed: 10000 Mbps now, 0 Mbps max
 2(s1-eth2): addr:b2:84:d9:29:cc:a9
     config:     0
     state:      0
     current:    10GB-FD COPPER
     speed: 10000 Mbps now, 0 Mbps max
 10(vtep): addr:5a:63:14:3d:64:27
     config:     0
     state:      0
     speed: 0 Mbps now, 0 Mbps max
 LOCAL(s1): addr:8a:27:12:84:6c:4e
     config:     PORT_DOWN
     state:      LINK_DOWN
     speed: 0 Mbps now, 0 Mbps max
OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0
root@openlab:~# 

下发流表

ovs-ofctl add-flow s1 "in_port=1,actions=set_field:10->tun_id,output:10"
ovs-ofctl add-flow s1 "in_port=10,tun_id=10,actions=output:1"

隧道出流量
主机连接ovs交换机的1端口,将从1端口进入的流量设置tun_id=10,然后转发到隧道的端口10
隧道入流量
对端隧道流量进入的端口为10,匹配进端口为10,tun_id=10的流量,转发给主机1

宣告arp

arp -s 172.171.3.104 00:1e:08:0c:99:38

ovs交换机的隧道外层封装时需要对端ip和mac,因为盛科交换机无法回复arp信息,所以需要手动宣告盛科交换机的local_ip以及bind_port中配置的端口的mac地址。

验证

原文地址:https://www.cnblogs.com/goldsunshine/p/14679931.html