CentOS / Redhat: KVM Bridged Network Configuration

Here’s how to set up a bridged network configuration in KVM on CentOS or Red Hat Enterprise Linux:

  1. Install the necessary packages:
sudo yum install -y qemu-kvm libvirt virt-install bridge-utils
  1. Create a bridge interface by editing the /etc/sysconfig/network-scripts/ifcfg-br0 file. Replace eth0 with the interface name you want to bridge:
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
STP=off
NM_CONTROLLED=no

# Add the physical network interface to the bridge
# Replace eth0 with the interface name you want to bridge
# You can add more than one interface to the bridge
# by repeating these lines with different interface names
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BRIDGE=br0

  1. Restart the network service to activate the new bridge:
sudo systemctl restart network
  1. Create a virtual machine with a bridged network interface:
sudo virt-install --name=vm1 --ram=2048 --vcpus=2 \
--disk path=/var/lib/libvirt/images/vm1.img,size=20 \
--network bridge=br0,model=virtio \
--cdrom=/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-2003.iso \
--os-variant=rhel7

Note that you can replace vm1 with the name of your virtual machine and adjust the other parameters to your needs.

  1. Start the virtual machine:
sudo virsh start vm1

Your virtual machine should now have access to the network through the bridge interface.

Leave a Comment