The Feiniu system has built-in Open vSwitch (OVS), which can directly bridge spare physical network ports into the main network bridge, allowing them to share the same Layer 2 domain with the main network port, essentially adding several switch ports without the need for additional hardware.

This article is based on a single extra network port environment, bridging enp4s0 into the OVS main bridge, and using the NetworkManager dispatcher script to make the configuration persist automatically after reboot.


Confirm the network port name and OVS status

First, go to the Feiniu System Settings → Network Settings to confirm the network port name, and enable OVS on the main network port. After enabling, a new bridge name ending with -ovs will appear for that port.

SSH into the Feiniu system, switch to root, and check the current OVS bridge information:

ovs-vsctl show

Example output:

84d44291904-...
    Bridge 84d44291904-ovs
        Port eno1
            Interface eno1
        Port 84d44291904-ovs
            Interface 84d44291904-ovs
                type: internal
    ovs_version: "3.1.0"

Note that the bridge name here is a UUID-style name automatically generated by Feiniu (like 84d44291904-ovs), not a readable name like eno1-ovs. This name will be used in the script later, and you should refer to the actual output of ovs-vsctl show.


Temporary bridging (lost after reboot)

If you only want to test temporarily, directly execute:

ovs-vsctl add-port 84d44291904-ovs enp4s0

It takes effect immediately, but the configuration disappears after the Feiniu system reboots (as of version 0.9.9). To make it persistent, you need the following script solution.


Use a dispatcher script to make the configuration take effect automatically on boot

Feiniu uses NetworkManager to manage the network, which supports triggering scripts when the network status changes. Scripts are placed in the /etc/NetworkManager/dispatcher.d/ directory. The idea is to listen for the event when the main bridge enters the up state, and after triggering, automatically execute the add-port command.

Navigate to the directory and create a new script:

cd /etc/NetworkManager/dispatcher.d/
nano 90-portstobridge

The script content is as follows:

#!/bin/bash
# 判断第一个参数是否是目标网桥,第二个参数是否是 up
if [ "$1" = "84d44291904-ovs" ] && [ "$2" = "up" ]; then
    ovs-vsctl add-port 84d44291904-ovs enp4s0
fi

Replace 84d44291904-ovs with the actual bridge name seen in ovs-vsctl show, and replace enp4s0 with the network port name you want to bridge.

After saving, give execute permissions:

chmod +x 90-portstobridge

The script is named 90-portstobridge, with the 90- prefix to ensure it runs after system scripts like 01-ifupdown — NetworkManager calls scripts in this directory in alphabetical order by file name, so larger numbers run later, ensuring that the OVS bridge is fully initialized before the port binding is executed.

Restart the NetworkManager service to verify it takes effect:

systemctl restart NetworkManager

After reconnecting, check the bridge status again:

ovs-vsctl show

If enp4s0 appears in the bridge port list, it means it is in effect.


Cancel Bridging

When no longer needed, manually delete the port:

ovs-vsctl del-port 84d44291904-ovs enp4s0

Also delete the script, otherwise it will be automatically rebuilt on the next reboot:

rm /etc/NetworkManager/dispatcher.d/90-portstobridge

Finally, go to the Feiniu backend and turn off the OVS switch for the corresponding network interface.

END

本文标题:飞牛系统用 OVS 实现虚拟网络交换机(重启有效)

本文链接:https://imsuk.cn/archives/292/

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

声明:转载请注明文章来源。

Last modification:May 23, 2026
请用钱砸我