A network bridge is a logical device that forwards traffic between connected physical interfaces based on MAC addresses. This kind of bridge can be used to emulate a hardware bridge in virtualization applications, such as KVM, to share the NIC with multiple virtual NICs.
To bridge two physical networks, we need two network interfaces. Your physical interfaces should never be configured with any address as the bridge will be configured with the IP address(es).
For the sake of ease, the physical network interfaces we will bridge are eth1
and eth2
. The IPv4 address will be 10.0.0.2
with a subnet mask of 255.0.0.0
and a default gateway of 10.0.0.1
.
Make sure that you activate the bridge after configuring the bridge and interfaces! Here are the steps that you need to perform for this:
~]# nmcli connection add type bridge ip4 10.0.0.2/8 gw4 10.0.0.1 Connection 'bridge' (36e40910-cf6a-4a6c-ae28-c0d6fb90954d) successfully added. ~]#
eth1
to the bridge, as follows:~]# nmcli connection add type bridge-slave ifname eth1 master bridge Connection 'bridge-slave-eth1' (6821a067-f25c-46f6-89d4-a318fc4db683) successfully added. ~]#
eth2
to the bridge using the following command:~]# nmcli connection add type bridge-slave ifname eth2 master bridge Connection 'bridge-slave-eth2' (f20d0a7b-da03-4338-8060-07a3775772f4) successfully added. ~]#
~# nmcli connection up bridge Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/30) ~]#
~]# nmcli connection show ~]# nmcli device status ~]# nmcli device show bridge
Here is an example output of the preceding commands:
Launch nmtui
and select Edit a connection. After this, follow these steps to create a bridge using nmtui
:
Edit your kickstart
file with your favorite editor through the following steps:
kickstart
file using this command line:... network --device=eth0 ...
network --device=bridge0 --bridgeslaves="eth1,eth2" --bootproto=static --ip=10.0.0.2 --netmask=255.0.0.0 --gateway=10.0.0.1
The options provided to create the bridge are bare bones using nmcli
. If you wish to add a connection and interface name, use con-name
and ifname
, respectively, in this way:
~# nmcli connection add type bridge con-name bridge0 ifname bridge0 ip4 10.0.0.2/8 gw4 10.0.0.1 Connection 'bridge0' (d04180be-3e80-4bd4-a0fe-b26d79d71c7d) successfully added. ~#
The same is true for adding the bridge slaves, except for ifname
, which is required to specify the correct interface:
~]# nmcli connection add type bridge-slave con-name bridge0-slave0 ifname eth1 master bridge0 Connection 'bridge0-slave0' (3a885ca5-6ffb-42a3-9044-83c6142f1967) successfully added. ~]# nmcli connection add type team-slave con-name team0-slave1 ifname eth2 master team0 Connection 'bridge0-slave1' (f79716f1-7b7f-4462-87d9-6801eee1952f) successfully added. ~]#