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:
- Install the necessary packages:
sudo yum install -y qemu-kvm libvirt virt-install bridge-utils- Create a bridge interface by editing the
/etc/sysconfig/network-scripts/ifcfg-br0file. Replaceeth0with the interface name you want to bridge:
DEVICE=br0
TYPE=BridgernBOOTPROTO=dhcprnONBOOT=yesrnDELAY=0
STP=offrnNM_CONTROLLED=nornrn# 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=EthernetrnONBOOT=yesrnBRIDGE=br0- Restart the network service to activate the new bridge:
sudo systemctl restart network- Create a virtual machine with a bridged network interface:
sudo virt-install --name=vm1 --ram=2048 --vcpus=2 n--disk path=/var/lib/libvirt/images/vm1.img,size=20 n--network bridge=br0,model=virtio n--cdrom=/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-2003.iso n--os-variant=rhel7Note that you can replace vm1 with the name of your virtual machine and adjust the other parameters to your needs.
- Start the virtual machine:
sudo virsh start vm1Your virtual machine should now have access to the network through the bridge interface.
