Creating a bridge

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.

Getting ready

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).

How to do it…

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.

Creating a bridge using nmcli

Make sure that you activate the bridge after configuring the bridge and interfaces! Here are the steps that you need to perform for this:

  1. First, create the bridge connection via the following command:
    ~]# 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.
    ~]#
    
  2. Add 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.
    ~]#
    
  3. Next, add 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.
    ~]#
    
  4. Activate the bridge by executing the following:
    ~# nmcli connection up bridge
    Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/30)
    ~]#
    
  5. Now, check your network connection by running the following commands:
    ~]# nmcli connection show
    ~]# nmcli device status
    ~]# nmcli device show bridge
    

    Here is an example output of the preceding commands:

    Creating a bridge using nmcli

Creating a bridge using nmtui

Launch nmtui and select Edit a connection. After this, follow these steps to create a bridge using nmtui:

  1. Create a bridge connection by selecting <Add> and Bridge from the connection list and then click on <Create>:
    Creating a bridge using nmtui
  2. Fill out the presented form with the required information:
    Creating a bridge using nmtui
  3. Next, add the two network interfaces by selecting <Add> and providing the requested information for each interface:
    Creating a bridge using nmtui
  4. Finally, select <OK> to create the bridge:
    Creating a bridge using nmtui

Your new bridge will now be listed in the connections list:

Creating a bridge using nmtui

Creating a bridge with kickstart

Edit your kickstart file with your favorite editor through the following steps:

  1. Look for the configuration parameters within your kickstart file using this command line:
    ...
    network --device=eth0
    ...
  2. Now, add the following configuration parameters:
    network --device=bridge0 --bridgeslaves="eth1,eth2" --bootproto=static --ip=10.0.0.2 --netmask=255.0.0.0 --gateway=10.0.0.1

There's more…

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.
~]#
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset