Create and Configure Bridge Networking For KVM in Linux

Posted on 329 views

In today’s guide, we will look at how to Create and Configure Bridge Networking For KVM in Linux – RHEL / CentOS / Ubuntu / Debian / Arch Linux e.t.c. Linux bridge when used in KVM, allows a Virtual Machine to Access external network and services outside of Virtual Environment.

There are various ways of configuring Bridge Networking in Linux for use in KVM. The default network used by a Virtual Machine launched in KVM is NAT network.With NAT networking, a virtual network is created for the guest machines which is then mapped to host network to provide internet connectivity.

When you configure and use Bridged networking, guest operating systems access external network connected directly to the host machine. A bridge can be created either using Virtual Machine Manager, using virsh command line tool, by directly editing network scripts or using Linux Network management tools.

Method 1: Creating Bridge Network using Virtual Machine Manager (NATed)

Follow these steps to create a Linux bridge from Virtual Machine Manager (GUI). You need to have installed KVM on your system. The demonstration done in this method is for NATed bridge setups.

How to install KVM on RHEL/CentOS 8Fedora, Arch LinuxCentOS, Ubuntu/Debian, SLES

Open Virtual Machine Manager, and go to Edit > Connection Details > Virtual Networks


Configure a new network interface by clicking the + at the bottom of the window. Give the virtual network a name.

virtual-machine-manager-network-name (1)

Click the Forward button, on next window, provide virtual network information.

virtual-machine-manager-network-information (1)

Click forward and choose if to enable IPv6.

virtual-machine-manager-ipv6 (1)

Select the network type and forwarding policy.

virtual-machine-manager-choose-route (1)

Finish the setting and save your configurations. The new Virtual network should show on the overview page.

virtual-machine-manager-network-created (1)

A bridge on the host system is automatically created for the network.

$ brctl show virbr4      
bridge name	bridge id		STP enabled	interfaces
virbr4		8000.525400c2410a	yes		virbr4-nic

Method 2: Create KVM bridge with virsh command.

Create a new bridge XML file.

vim br10.xml

Add bridge details to the file.


To define a network from an XML file without starting it, use:

$ sudo virsh net-define  br10.xml
Network br1 defined from br10.xml

To start a (previously defined) inactive network, use:

$ sudo virsh net-start br10
Network br10 started

To set network to autostart at service start:

$ sudo virsh net-autostart br10
Network br10 marked as autostarted

Check to Confirm if autostart flag is turned to yes – Persistent should read yes as well.

$ sudo virsh net-list --all
 Name              State    Autostart   Persistent
 br10              active   yes         yes
 default           active   yes         yes
 docker-machines   active   yes         yes
 fed290            active   no          yes
 vagrant-libvirt   active   no          yes

Confirm bridge creation and IP address.

$ ip addr show dev br10
28: br10:  mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:94:00:f5 brd ff:ff:ff:ff:ff:ff
    inet brd scope global br10
       valid_lft forever preferred_lft forever

Method 3: Create a bridge by editing network scripts (CentOS / RHEL / Fedora):

Below script will create a bridge called br10.

sudo vim /etc/sysconfig/network-scripts/ifcfg-br10



The configuration of eth0 interface that I’m bridging to will be:

$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 

Bring up the interfaces:

sudo ifdown br10
sudo ifup br10

Method 4: Create a bridge by editing network scripts (Debian / Ubuntu):

Configure Bridging interface:

$ sudo vim  /etc/network/interfaces
auto br10 
iface br10 inet static
bridge_ports eth0
bridge_stp off

Disable all lines on eth0 interface section to look something like below:

auto eth0
iface eth0 inet manual

Restart your networking service.

 sudo systemctl restart networking.service

Method 5: Using Nmcli tool

Use the nmcli network management command line tool to create a Linux bridge on the desired interface. Let’s first list all available connections.

$ sudo nmcli connection show 
NAME                UUID                                  TYPE      DEVICE 
enp1s0              498869bb-0d88-4a4c-a83a-c491d1040b0b  ethernet  enp1s0 
Wired connection 1  0977f29f-fa2e-3d7f-831c-6f41f8782be3  ethernet  enp7s0 

Since my bridge will be created on the second device enp7s0, I’ll delete the existing connection then create a bridge with this device.

$ sudo nmcli connection delete 0977f29f-fa2e-3d7f-831c-6f41f8782be3
Connection 'Wired connection 1' (0977f29f-fa2e-3d7f-831c-6f41f8782be3) successfully deleted.

1. Save bridge related information to variables.



  • BR_NAME: The name of the bridge to be created.
  • BR_INT: the physical network device to be used as bridge slave.
  • SUBNET_IP: IP address and subnet assigned to the bridge created.
  • GW: The IP address of the default gateway
  • DNS1 and DNS2: IP addresses of DNS servers to be used.

2. Define new bridge connection.

sudo nmcli connection add type bridge autoconnect yes con-name $BR_NAME ifname $BR_NAME


Connection 'br0' (be6d4520-0257-49c6-97c2-f515d6554980) successfully added.

3. Modify bridge to add IP address, Gateway and DNS

sudo nmcli connection modify $BR_NAME ipv4.addresses $SUBNET_IP ipv4.method manual
sudo nmcli connection modify $BR_NAME ipv4.gateway $GW
sudo nmcli connection modify $BR_NAME ipv4.dns $DNS1 +ipv4.dns $DNS2

4. Add the network device as bridge slave.

sudo nmcli connection delete $BR_INT
sudo nmcli connection add type bridge-slave autoconnect yes con-name $BR_INT ifname $BR_INT master $BR_NAME

Sample output.

Connection 'enp7s0' (f033dbc9-a90e-4d4c-83a9-63fd7ec1cdc1) successfully added.

Check connections.

$ sudo nmcli connection show 
NAME    UUID                                  TYPE      DEVICE 
br0     be6d4520-0257-49c6-97c2-f515d6554980  bridge    br0    
enp1s0  498869bb-0d88-4a4c-a83a-c491d1040b0b  ethernet  enp1s0 
enp7s0  f033dbc9-a90e-4d4c-83a9-63fd7ec1cdc1  ethernet  enp7s0 

Step 2: Bring up network bridge

Once the network bridge connection has been created, bring it up.

$ sudo nmcli connection up br10
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)

View bridge details by running.

sudo nmcli connection show br10

The ip addr command should give output similar to below.

$ ip ad
3: enp7s0:  mtu 1500 qdisc fq_codel master br10 state UP group default qlen 1000
     link/ether 52:54:00:a2:f6:a8 brd ff:ff:ff:ff:ff:ff
 4: br10:  mtu 1500 qdisc noqueue state UP group default qlen 1000
     link/ether 52:54:00:a2:f6:a8 brd ff:ff:ff:ff:ff:ff
     inet brd scope global noprefixroute br10
        valid_lft forever preferred_lft forever
     inet6 fe80::4f2f:ce6d:dc6b:2101/64 scope link noprefixroute 
        valid_lft forever preferred_lft forever

Congratulations!!. You have successfully created and configured Bridge Networking for KVM on a Linux system.

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.