How To Create Bridged Network in Libvirt

Setting up a bridge network in a virtualization environment is essential for enabling virtual machines (VMs) to communicate both with each other and with the external network. In Linux environments managed by Libvirt, this can be accomplished through XML-based configuration.

Using XML not only ensures persistence across reboots but also provides a powerful and flexible way to define and manage network settings with precision and ease.

📖 This is just one chapter’s insight from Mastering KVM Virtualization. Get the full breakdown and unlock more advanced topics. Download the eBook.

Step 1: Create XML Configuration File

Start be creating a new XML file for your bridge network, e.g., bridge-network.xml.

vim bridge-network.xml

Below is an example XML configuration:

  • Bridge without DHCP service. You will set IP address information manually on the instance.
<network>
  <name>br0</name>
  <forward mode='bridge'/>
  <bridge name='br0'/>
  <mtu size='1500'/>
</network>
  • Bridge with DHCP service – VMs will get IP allocations from defined IP block.
<network>
  <name>br0</name>
  <forward mode='bridge'/>
  <bridge name='br0'/>
  <ip address='192.168.10.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.10.20' end='192.168.10.200'/>
    </dhcp>
  </ip>
</network>
  • With DNS Forwarding. The DNS forwarders configured are google public ones.
<network>
  <name>br0</name>
  <forward mode='bridge'/>
  <bridge name='br0'/>
  <ip address='192.168.10.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.10.20' end='192.168.10.200'/>
    </dhcp>
  </ip>
  <dns>
    <forwarder addr='8.8.8.8'/>
    <forwarder addr='8.8.4.4'/>
  </dns>
</network>

Exaplanations:

  • In this example:
  • <name>: Specifies the name of the network.
  • <forward mode='bridge'/>: Indicates that the network operates in bridge mode.
  • <bridge name='br0'/>: Specifies the name of the bridge interface to use.
  • The other settings are for IP address, DHCP and DNS forwarders accordingly

Step 2: Define the Network in Libvirt

Use the virsh command to define the network with the XML configuration file.

virsh net-define bridge-network.xml

Step 3: Start and Autostart the Network

Use the commands below to start the network and set it to start automatically

virsh net-start br0
virsh net-autostart br0

Step 4: Verify the Network

List available networks in your KVM host by running the following commands

virsh net-list --all

To output the network information as an XML dump to stdout, use:

virsh net-dumpxml <network>
# Example virsh net-dumpxml br0

You can also get basic information about the network object.

virsh net-info <network>

By leveraging Libvirt’s XML configuration for bridge networking, administrators gain a reliable and scalable approach to connecting VMs. This method balances simplicity with fine-grained control, ensuring that virtualized environments remain both flexible and resilient to future changes.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Unlock the Right Solutions with Confidence

At CloudSpinx, we don’t just offer services - we deliver clarity, direction, and results. Whether you're navigating cloud adoption, scaling infrastructure, or solving DevOps challenges, our seasoned experts help you make smart, strategic decisions with total confidence. Let us turn complexity into opportunity and bring your vision to life.

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

A pre-configured operating system can be saved as a template for faster virtual machines creation as day 2 operation. In […]

Are you looking for the best eBook to learn and master Ubuntu Desktop OS? Whether you’re a beginner switching from […]

KeeWeb is an open source cross-platform network manager. It comes with features such as cloud sync, plugin support and keyboard […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.