25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to configure network bridge for KVM virtual machines in Linux

by | Oct 8, 2020

Trying to configure a network bridge for KVM virtual machines? Here’s how we do it.

Here at Bobcares, we have seen several such KVM related queries as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at configuring network bridge for KVM virtual machines.

 

Know more about KVM virtual machines

When a Linux bridge is used in KVM, it allows a virtual machine to access external networks and services outside of the virtual environment. Bridged networking is a dedicated network card to a virtual machine that provides a communication path to the outside networks. Also, this must be set up before creating a virtual machine using Virtual Manager.

Moreover, there are different ways to configure the Bridge Networking in Linux for use in KVM. By default, the Virtual Machine launched in KVM uses a NAT network.

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

 

How to configure a network bridge for KVM virtual machines

Now let’s take a look at how to configure the network bridge.

 

Method 1: Creating Bridge Network using Virtual Machine Manager

Here are the steps to create a Linux bridge from Virtual Machine Manager (GUI). Make sure that you have installed KVM on your system.

1. Firstly, open Virtual Machine Manager, and go to Edit > Connection Details > Virtual Networks. Suppose the device name is virbr.
2. Next, click the + at the bottom of the window to configure a new network interface. Here, give the virtual network a name. For example, br1.
3. Then click the Forward button, in the next window, provide virtual network information.
4. After that, click forward and choose if to enable IPv6.
5. Now select the network type and forwarding policy.
6. Finish the setting and save the configurations. As a result, the new Virtual network must display on the overview page.
7. Finally, a bridge on the host system is automatically created for the network.

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

 

Method 2: Create KVM bridge with virsh command

First, create a new bridge XML file.

$ vim br1.xml

Then add the below details in the file.


br10











To define a network from an XML file without starting it. So run the below command.

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

To start a (previously defined) inactive network, run the below command.

$ sudo virsh net-start br1
Network br1 started

To set network to autostart at service start, run the below command.

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

Then, confirm if the autostart flag is turned to yes. In the result, the Persistent should read yes as well.

$ sudo virsh net-list –all

Also, make sure to confirm bridge creation and IP address.

$ ip addr show dev br1

 

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

Here is a script that creates a bridge called br1.

$ sudo vim /etc/sysconfig/network-scripts/ifcfg-br1

With:

DEVICE=br1
STP=no
TYPE=Bridge
BOOTPROTO=none
DEFROUTE=yes
NAME=br1
ONBOOT=yes
DNS1=8.8.8.8
DNS2=192.168.30.1
IPADDR=192.xxx.xx.x
PREFIX=24
GATEWAY=192.xxx.xx.x

Here is the configuration of eth0 interface to which br1 will be bridged:

$ cat /etc/sysconfig/network-scripts/ifcfg-eno1
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BRIDGE=br1

Finally, restart the network daemon.

$ sudo systemctl disable NetworkManager && sudo systemctl stop NetworkManager
$ sudo systemctl restart network.service

 

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

To configure the bridging interface, run the below command.

$ sudo vim /etc/network/interfaces
auto br1
iface br1 inet static
address 192.xxx.xx.xx
network 192.xxx.x.x
netmask 255.255.255.0
broadcast 192.xxx.x.xxx
gateway 192.xxx.x.x
dns-nameservers 192.xxx.x.x
bridge_ports eth0
bridge_stp off

Then disable all the lines on eth0 interface section so that it looks something like below:

auto eth0
iface eth0 inet manual

Finally, restart the networking service.

$ sudo systemctl restart networking.service

[Need any further assistance with KVM queries? – We’re available to help you]

 

Conclusion

Today, we saw how to configure a network bridge for KVM virtual machines.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF