Designing a Linux virtual network for KVM virtualization

In a KVM virtual environment, one of the most complicated aspects of virtual hardware to set up is the virtual network. In this article you'll read some tips on how to set up the network interfaces.

When configuring virtual networks, there are two parts. First, is configuring the physical network cards in the host operating system. Next is the virtual network interfaces within the virtual machines.

Physical versus virtual network configurations
Before starting to configure the virtual network, you need to decide what exactly you want to configure. In modern networks, many different configuration scenarios are possible as servers are often equipped with several network cards. The fact that your server has more than network card, brings you to the first important question: Are you going to use these cards for increased performance and redundancy in a NIC teaming configuration? Or are you going to configure the network cards individually so that you can assign specific virtual machines to specific network cards?

    Requires Free Membership to View

More on KVM virtualization
Red Hat explains shift from Xen to KVM

Creating KVM virtual machines in RHEL 5.4

Virtualization options for enterprise Linux

The are reasons to prefer either of these two methods. If the workload on your virtual machine doesn't show one or more virtual machines that have considerably higher network I/O than other machines, the best way to configure the virtual network, is probably by setting up a NIC bonding configuration in the host operating system. Most Linux distributions offer solutions to set up such an environment. The result is that instead of using individual network cards, you'll be working with one network interface, the bond0 interface. On top of this bond0 interface, you would create the virtual bridge interface (similar to the working of a real switch). All the individual virtual machines will then be using ports on this virtual bridge, without priority, for any of the virtual machines.

The advantage of this scenario is that the host operating system takes care of assigning equal priority to the available virtual machines. Also, the network bonding interface ensures that you have redundancy implemented in your network. If one of the interfaces in the bond environment goes down, the other interface(s) can take over, ensuring continuing networking.

Manual priority assignments
You can choose not to bundle the physical network interfaces in your host operating system to one big bonding device. This approach also offers some advantages, namely that you can manually determine which virtual machine is going to use which virtual network card. Imagine an environment where you have four virtual machines, running on one host server. In the host server, you have two network interfaces, but one of the virtual machines is causing a considerably higher workload than the other virtual machines. In such a situation you are better of using two (or more) different network interfaces. What you would do, is configure a bridge on each of the interfaces and assign the virtual machine that has high bandwidth demands exclusively to one of the interfaces, where you can assign all other virtual machines to the other interfaces. This way you can manually load balance the virtual machines over the network.

You could also configure networking within the virtual machines. There's nothing that prevents you from creating a network bonding device within a virtual machines. From a more practical perspective, this is not a good idea. If you configure networking on the host, all virtual machines can use that configuration. If you configure networking within the virtual machines, you would need to repeat the network configuration procedure for each virtual machine.

KVM network set-up best practices
When setting up KVM networking, you can configure the physical network cards in your server in one bonding device that communicates with one network bridge. This is the best approach if all the virtual machines that you expect to be using on this host have similar needs for network bandwidth usage. If there are considerable differences with regard to the bandwidth needs of virtual machines, it is better to create multiple virtual bridges, so that machines that have high bandwidth needs can have a dedicated network bridge.

ABOUT THE AUTHOR: Sander van Vugt is an author and independent technical trainer, specializing in Linux since 1994. Vugt is also a technical consultant for high-availability (HA) clustering and performance optimization, as well as an expert on SLED 10 administration.

This was first published in January 2010

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.