如何在 open-vswitch 中将流量从特定端口转发到另一个端口

How can I forward traffic from a specific port to another in open-vswitch

我正在尝试将 ovs 设置为中转交换机。这将用于为 docker 容器创建数据网络。

即在下图中,我能够将 veth0-veth3 和 veth100 添加到 veth103 到 ovs。但我想配置所有来自 veth0 的流量都转到 veth100,反之亦然。类似地,veth1-veth101、veth2-veth102、veth3-veth103 对。 一种方法是使用 vlan,但如果可能的话,我想避免这样做。 是否存在允许如上所述固定端口的配置?

                Openvswitch              
              +-------------+              
veth0  +------+             +--veth100--
veth1  +------+             +--veth101--
veth2  +------+             +--veth102--
veth3  +------+             +--veth103-- 
              +-------------+

这可以通过以下命令完成:

ovs-ofctl add-flow <Bridge> in_port=<src_Port>,actions=<Action>

<Action>中把目标端口如下:

output:destination_port