Configuring a New RHEL 6 KVM Virtual Network

From Techotopia
Revision as of 16:55, 16 December 2010 by Neil (Talk | contribs)

Jump to: navigation, search
PreviousTable of ContentsNext
Creating RHEL 6 Hosted KVM Virtual Machines with virt-install and virshManaging KVM on RHEL 6 using the virsh Command-line Tool


When KVM virtualization is installed on Red Hat Enterprise Linux 6 a single virtual network is created by default. The goal of this chapter is to provide an overview of virtual networks in the context and RHEL 6 and KVM and to explain the steps involved in adding additional virtual networks to the host environment.


RHEL 6 KVM Guest Networking Options

KVM based virtual machines running on a Red Hat Enterprise Linux 6 host are provided two choices in terms of network connectivity. One option is to use a network bridge that essentially allows the guest operating system to share one of the host system’s network connections. This connection option is also referred to as a shared physical device since both the host operating system and guest OS are both utilizing a physical network adaptor to gain network access. Details on the creation of network bridges were provided in the chapter entitled Creating an RHEL 6 KVM Networked Bridge Interface.

In this shared physical device scenario, the guest operating system appears on the external network in the same way as any other systems directly connected to the network. It will need, for example, an IP address within the address space of the external network, or will be assigned an IP address from a DHCP server in the same way as all other systems on the network. The second option involves connecting the virtual machine to a virtual network. A virtual network is essentially a software based network that runs within the host RHEL 6 operating system. The virtual network has its own range of IP addresses and operates a DHCP server to assign IP addresses to connected virtual machines. Connection to the external network, if enabled, is typically provided using Network Address Translation (NAT), whereby the guest OS connects using the IP address of the host system. By default a single virtual network is created when KVM is installed on an RHEL 6 system. It is named default and uses a virtual networking device called virbr0.

Identifying the Settings of an Existing RHEL 6 KVM Virtual Network

The best way to identify the settings of a KVM virtual network is to use the virt-manager tool. This tool may be launched by selecting the Applications -> System Tools -> Virtual Machine Manager desktop menu item. Once loaded, select the Edit -> Host Details menu option and on the resulting dialog, select the Virtual Networks tab as illustrated in the following figure:

The default virtual network on a RHEL 6 KVM host

As we can see from the information provided by virt-manager, the only virtual network currently available is named default. It uses the virtual device named virbr0, has an IP address space defined by with a subnet mask of 24. The DHCP server is configured to allocated IP addresses between and Forwarding to the external network is handled using NAT. The virtual network is currently active and is configured to start on system boot.

The buttons beneath the list of networks can be used to start, stop or delete the currently selected network. In addition, the button displaying the + sign can be used to create a new virtual network, a topic that will be covered in the next section of this chapter.

Creating a New KVM Virtual Network on an RHEL 6 Host

To create a new KVM virtual network on an RHEL host, click on the + button located beneath the list of virtual networks on the Virtual Networks details screen outlined in the previous section. The Create a new virtual network wizard will appear. After reading the introductory screen, click on the Forward button and enter a name for the new virtual network. For the purposes of this example we will use the name virtualnet1. Having defined the name, click the Forward button to proceed to the address space configuration screen:

Specifying the IF address space for an RHEL 6 KVM virtual network

Either select the default setting, or specify an alternative if a specific address space is required before proceeding to the next screen where the DHCP address range must be defined:

Specifying the DHCP address range for an RHEL 6 KVM virtual network

The wizard will pre-populate start and end address for the DHCP server based on the IP address space specified on the preceding screen. Unless a guest OS is configured with a static IP address, it will be assigned an IP address from the range specified on this screen when it is started up.

On the next screen the network may be configured to be an isolated network or for data to be forwarded to a physical network. In the case of an isolated network, guests connected to this virtual network can see each other but have absolutely no connectivity to the external physical network.

If the Forwarding to a physical network option is selected a specific physical network device on the host system may be selected, or the system can be left to select any available networking device. Lastly, the forwarding mode may be configured to use NAT or Routed forwarding:

RHEL 6 KVM forwarding options for a new virtual network

After the network connectivity options have been defined, the final screen displays a summary of the selections made on the preceding screens. Review the information provided and, assuming the settings match your requirements, click on Finish to create the new virtual network.

On returning to the main Host Details screen, select the new virtual network from the list to view the settings:

A new virtual network created on a KVM RHEL 6 host

The new virtual network should reflect the specified configuration options. In addition we can see that it has been assigned virtual device virbr1, is already active and is configured to start when the host system boots.

Assigning the New Virtual Bridge during Virtual Machine Creation

During the virtual machine creation process the creation wizard will display a network configuration screen. In order to connect the virtual machine to the newly created virtual network simply ensure that the Virtual Network option is selected and then choose the new network by name from the drop down menu. The following figure shows the Advanced options section of the final configuration screen set up to use the virtualnet1 network created in the preceding section:

Connecting an RHEL 6 based KVM guest to a new virtual network

Changing an Existing Virtual Machine to Use a new Virtual Network

An existing virtual machine may also be configured to use a new virtual network. To make this configuration change, select the virtual machine from the main screen of the virt-manager tool and click on the Open button located in the toolbar. When the virtual machine window appears, click on the blue information button to display the current configuration. In the list of hardware categories click on the NIC entry.

In order to configure the virtual machine to use the new virtual network it is necessary to first delete this NIC from the configuration by clicking on the Remove button located in the bottom right hand corner of the dialog. Once the old NIC has been deleted, click on the Add Hardware button to display the Add new virtual hardware wizard, select Network from the hardware type menu and click the Forward button. On the resulting network configuration screen, select the new virtual network from the Host device menu.

Click the Forward button, review the summary information and click Finish to commit the changes. When the virtual machine is next powered up it will be connected to the new virtual network.


PreviousTable of ContentsNext
Creating RHEL 6 Hosted KVM Virtual Machines with virt-install and virshManaging KVM on RHEL 6 using the virsh Command-line Tool