在 CentOS 8 中使用 NetworkManager 设置 Open vSwitch 的正确方法是什么?

Ole*_*kin 2 redhat networkmanager openvswitch

过去的美好时光是怎样的network-scripts

我在文件中描述了桥和端口:

/etc/sysconfig/network-scripts/ifcfg-br0
/etc/sysconfig/network-scripts/ifcfg-port0
Run Code Online (Sandbox Code Playgroud)

比重新启动网络

systemctl restart network
Run Code Online (Sandbox Code Playgroud)

一切开始工作。

现在network-scripts被标记为deprecated,有一个警告will be removed in one of the next major releases of RHEL.,所以我必须切换到NetworkManager,对吧?

但如何使用 NetworkManager 设置 Open vSwitch?

我已经安装NetworkManager-ovs并尝试了本指南,但描述的命令没有执行任何操作,我的意思是输出中没有出现任何内容ovs-vsctl show

nmcli networking off && nmcli networking onsystemctl restart NetworkManager没有任何影响

ifup br0也不起作用:

Error: unknown connection '/etc/sysconfig/network-scripts/ifcfg-br0'.
Run Code Online (Sandbox Code Playgroud)

小智 5

创建具有单个内部接口的桥

$ nmcli conn add type ovs-bridge conn.interface bridge0
Connection 'ovs-bridge-bridge0' (d10fc64d-1d48-4394-a1b8-e1aea72f27d5) successfully added.

$ nmcli conn add type ovs-port conn.interface port0 master bridge0
Connection 'ovs-port-port0' (5ae22bae-bba4-4815-9ade-7e635633e1f0) successfully added.

$ nmcli conn add type ovs-interface slave-type ovs-port conn.interface iface0 \
  master port0 ipv4.method manual ipv4.address 192.0.2.1/24
Connection 'ovs-interface-iface0' (3640d2a1-a2fd-4718-92f1-cffadb5b6cdc) successfully added.
Run Code Online (Sandbox Code Playgroud)

即使是单个接口,您也需要创建一个端口。此外,在添加接口之前,桥接器和端口设备显示为活动状态,但尚未在 OVSDB 中配置。您可以使用 ovs-vsctl show 检查结果。

将 Linux 接口添加到 Bridge

$ nmcli conn add type ovs-port conn.interface port1 master bridge0
Connection 'ovs-port-port1' (67d041eb-8e7b-4458-afee-a1d07c9c4552) successfully added.
$ nmcli conn add type ethernet conn.interface eth0 master port1
Connection 'ovs-slave-eth0' (d459c45c-cf78-4c1c-b4b7-505e71379624) successfully added.
Run Code Online (Sandbox Code Playgroud)

现在运行 ovs-vsctl show 并检查它。