16.7. Configuring bridges on a network bond to connect virtual machines with the network


The network bridge connects VMs with the same network as the host. If you want to connect VMs on one host to another host or VMs on another host, a bridge establishes communication between them. However, the bridge does not provide a fail-over mechanism.

To handle failures in communication, a network bond handles communication in case of failure of a network interface. To maintain fault tolerance and redundancy, the active-backup bonding mechanism determines that only one port is active in the bond and does not require any switch configuration. If an active port fails, an alternate port becomes active to retain communication between configured VMs in the network.

To configure a network bond on the command line, use the nmcli utility.

Prerequisites

  • Two or more physical devices are installed on the server, and they are not configured in any NetworkManager connection profile.

Procedure

  1. Create a bond interface:

    # nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup"

    This command creates a bond named bond0 that uses the active-backup mode.

  2. Assign the Ethernet interfaces to the bond:

    # nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname enp7s0 master bond0
    # nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname enp8s0 master bond0

    These commands create profiles for enp7s0 and enp8s0, and add them to the bond0 connection.

  3. Configure the IPv4 settings:

    • To use DHCP, no action is required.
    • To set a static IPv4 address, network mask, default gateway, and DNS server to the bond0 connection, enter:

      # nmcli connection modify bond0 ipv4.addresses 192.0.2.1/24 ipv4.gateway 192.0.2.254 ipv4.dns 192.0.2.253 ipv4.dns-search example.com ipv4.method manual
  4. Configure the IPv6 settings:

    • To use stateless address autoconfiguration (SLAAC), no action is required.
    • To set a static IPv6 address, network mask, default gateway, and DNS server to the bond0 connection, enter:

      # nmcli connection modify bond0 ipv6.addresses 2001:db8:1::1/64 ipv6.gateway 2001:db8:1::fffe ipv6.dns 2001:db8:1::fffd ipv6.dns-search example.com ipv6.method manual
  5. Optional: If you want to set any parameters on the bond ports, use the following command:

    # nmcli connection modify bond0-port1 bond-port.<parameter> <value>
  6. Configure that Red Hat Enterprise Linux enables all ports automatically when the bond is enabled:

    # nmcli connection modify bond0 connection.autoconnect-ports 1
  7. Activate the bridge:

    # nmcli connection up bond0

Verification

  1. Temporarily remove the network cable from the host.

    Note that there is no method to properly test link failure events using software utilities. Tools that deactivate connections, such as nmcli, show only the bonding driver’s ability to handle port configuration changes and not actual link failure events.

  2. Display the status of the bond:

    # cat /proc/net/bonding/bond0

A network bridge for network bonds involves configuring a bond interface that combines multiple network interfaces for improved traffic handling. Therefore, VMs can access the network through the bonded network interfaces by using the network bridge. The nmcli utility creates and edits connection files from the command line required for the configuration.

Procedure

  1. Create a bridge interface:

    # nmcli connection add type bridge con-name br0 ifname br0 ipv4.method disabled ipv6.method disabled
  2. Add the bond0 bond to the br0 bridge:

    # nmcli connection modify bond0 master br0
  3. Configure that Red Hat Enterprise Linux enables all ports automatically when the bridge is enabled:

    # nmcli connection modify br0 connection.autoconnect-ports 1
  4. Reactivate the bridge:

    # nmcli connection up br0

Verification

  • Use the ip utility to display the link status of Ethernet devices that are ports of a specific bridge:

    # ip link show master br0
    6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
        link/ether 52:54:00:38:a9:4d brd ff:ff:ff:ff:ff:ff
    ...
  • Use the bridge utility to display the status of Ethernet devices that are ports of any bridge device:

    # bridge link show
    6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100
    ...

    To display the status for a specific Ethernet device, use the bridge link show dev <ethernet_device_name> command.

To enable virtual machines (VM) to use the br0 bridge with the bond, first add a virtual network to the libvirtd service that uses this bridge.

Prerequisites

  • You installed the libvirt package.
  • You started and enabled the libvirtd service.
  • You configured the br0 device with the bond on Red Hat Enterprise Linux.

Procedure

  1. Create the ~/bond0-bridge.xml file with the following content:

    <network>
    	<name>bond0-bridge</name>
    	<forward mode="bridge" />
    	<bridge name="br0" />
    </network>
  2. Use the ~/bond0-bridge.xml file to create a new virtual network in libvirt:

    # virsh net-define ~/bond0-bridge.xml
  3. Remove the ~/bond0-bridge.xml file:

    # rm ~/bond0-bridge.xml
  4. Start the bond0-bridge virtual network:

    # virsh net-start bond0-bridge
  5. Configure the bond0-bridge virtual network to start automatically when the libvirtd service starts:

    # virsh net-autostart bond0-bridge

Verification

  • Display the list of virtual networks:

    # virsh net-list
    Name              State    Autostart   Persistent
    ----------------------------------------------------
    bond0-bridge      active      yes         yes
    ...

To configure a VM to use a bridge device with a bond interface on the host, create a new VM that uses the bond0-bridge virtual network or update the settings of existing VMs to use this network.

Perform this procedure on the RHEL hosts.

Prerequisites

  • You configured the bond0-bridge virtual network in libvirtd.

Procedure

  1. To create a new VM and configure it to use the bond0-bridge network, pass the --network network:bond0-bridge option to the virt-install utility when you create the VM:

    # virt-install ... --network network:bond0-bridge
  2. To change the network settings of an existing VM:

    1. Connect the VM’s network interface to the bond0-bridge virtual network:

      # virt-xml <example_vm> --edit --network network=bond0-bridge
  3. Shut down the VM, and start it again:

    # virsh shutdown <example_vm>
    # virsh start <example_vm>

Verification

  • Display the virtual network interfaces of the VM on the host:

    # virsh domiflist <example_vm>
    Interface   Type     Source           Model    MAC
    -------------------------------------------------------------------
    vnet1       bridge   bond0-bridge   virtio   52:54:00:c5:98:1c
  • Display the interfaces attached to the br0 bridge:

    # ip link show master br0
    18: bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 2a:53:bd:d5:b3:0a brd ff:ff:ff:ff:ff:ff
    
    19: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:c5:98:1c brd ff:ff:ff:ff:ff:ff
    ...

    Note that the libvirtd service dynamically updates the bridge’s configuration. When you start a VM which uses the bond0-bridge network, the corresponding vnet* device on the host is displayed as a port of the bridge.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部