This article shows how the primary network interface could be replaced by a bridge device and the network interface becomes a part of the bridge as a slave device without reboot or restart of the server. Using nmcli under CentOS 8 (and probably any other Linux distribution like Ubuntu, which uses NetworkManager to configure network devices).
The main steps are:
- Create a connection profile of a bridge device.
- Set the same network configuration as the primary network to the bridge device.
- Create a connection profile for the primary interface device as a slave network device to the newly created bridge.
- Delete the current primary connection, which is using the primary network device and configuration.
- Reload the bridge connection profile to take effect. The bridge device will actually begin to work.
The main goal is not to reboot the server or lose the connection to the server. The primary network interface is the only connection on the server and losing it the server is going to be unreachable. So the last two steps should be performed in the background or a script or a detached terminal (like screen).
Here are all the commands in one place:
nmcli connection add type bridge ifname br0 con-name br0 ipv4.method manual ipv4.addresses "192.168.0.20/24" ipv4.gateway "192.168.0.1" ipv4.dns "18.104.22.168 22.214.171.124" nmcli con add type bridge-slave ifname enp0s3 master br0 nmcli con del "enp0s3"; nmcli con reload "br0" &
Here is the detailed information for the above commands:
Keep on reading!