Setting up a network bridge using nmcli on CentOS 7
In CentOS 6, if you wanted to set up a network bridge, it was advised to disable NetworkManager and do it manually. In CentOS 7, this is not quite an option because NetworkManager is now more integral to the OS. However, it is possible in CentOS 7 to create and configure a bridge using NetworkManager. This article shows you how to achieve this using NetworkManager's nmcli command.
(1) Create a bridge named bridge-br0.
[root@host]# nmcli con add type bridge ifname br0
(2) Disable spanning tree protocol (STP)
[root@host]# nmcli con modify bridge-br0 bridge.stp no
(3) Set the IP address, etc. (adjust the parameters appropriately)
[root@host]# nmcli con modify bridge-br0 ipv4.method manual ipv4.address "192.168.199.100/24" ipv4.gateway "192.168.199.254" ipv4.dns 22.214.171.124 ipv4.dns-search example.com
Note that, in CentOS 7.0, the syntax was 'ipv4.addresses 192.168.199.100/24 192.168.199.254'. This has been changed in the later minor versions.
(4) Connect the physical port enp0s25 to the bridge just created.
[root@host]# nmcli con add type bridge-slave ifname enp0s25 master bridge-br0
(5) Delete the physical port and reboot the system immediately as the connection will be lost
[root@host]# nmcli con del enp0s25; reboot
If your host uses dhcp, not static IP, skip steps (3) and (5).