Managing Virtual Networks 2.0
A cluster node is connected to one or more networks that are available to the virtual machines through the corresponding bridges. To set up a virtual networks you just need to know the name of the bridge to bind the virtual machines to.
In this guide you'll learn how to define and use virtual networks. For the sake of completeness the following examples assumes that the cluster nodes are attached to two physical networks:
OpenNebula allows for the creation of Virtual Networks by mapping them on top of the physical ones. All Virtual Networks are going to share a default value for the MAC preffix, set in the
There are two types of Virtual Networks in OpenNebula:
A fixed network consists of a set of IP addresses and associated MACs, defined in a text file.
We need four pieces of information to define a fixed VN:
MAC = MAC_PREFFIX:IP. So, for example, from IP 10.0.0.1 and MAC_PREFFIX 00:16, we get 00:16:0a:00:00:01. Defining only a MAC address with no associated IP is not allowed.
For example to create a Fixed Virtual Network, called
Public with the set of public IPs to be used by the VMs, just create a file with the following contents:
NAME = "Public" TYPE = FIXED #We have to bind this network to ''virbr1'' for Internet Access BRIDGE = vbr1 LEASES = [IP=18.104.22.168, MAC=50:20:20:20:20:20] LEASES = [IP=22.214.171.124, MAC=50:20:20:20:20:21] LEASES = [IP=126.96.36.199] LEASES = [IP=188.8.131.52]
This type of VNs allows for a definition supported by a base network address and a size. So we need to define:
The following is an example of a Ranged Virtual Network template:
NAME = "Red LAN" TYPE = RANGED # This vnet can be only used by the owner user PUBLIC = NO #Now we'll use the cluster private network (physical) BRIDGE = vbr0 NETWORK_SIZE = C NETWORK_ADDRESS = 192.168.0.0
Default value for the network size can be found in
Once a template for a VN has been defined, the
onevnet command can be used to create it.
To create the previous networks put their definitions in two different files,
red.net, respectively. Then, execute:
$ onevnet -v create public.net $ onevnet -v create red.net
onevnet can be used to query OpenNebula about available VNs:
$ onevnet list ID USER NAME TYPE BRIDGE P #LEASES 2 oneadmin Public Fixed vbr1 Y 0 3 oneadmin Red LAN Ranged vbr0 N 0with
USERthe owner of the network and
#LEASESthe number of IP-MACs assigned to a VM from this network.
To delete a virtual network just use
onevnet delete. For example to delete the previous networks:
$onevnet delete 2 $onevnet delete 'Red LAN'
onevnet command help or reference guide for more options to list the virtual networks.
A lease from a virtual network can be obtained by simply specifying the virtual network name in the
For example, to define VM with two network interfaces, one connected to
Red LAN and other connected to
Public just include in the template:
NIC=[NETWORK="Public"] NIC=[NETWORK="Red LAN"]
You can also request an specific address just by adding the
MAC attributes to
NIC=[NETWORK="Red LAN", IP=192.168.0.3]
When the VM is submitted, OpenNebula will look for available IPs in the
Red LAN virtual networks. If successful, the
onevm show command should return information about the machine, including network information.
$ onevm show 12 VIRTUAL MACHINE 12 INFORMATION ID : 12 NAME : server STATE : PENDING LCM_STATE : LCM_INIT START TIME : 07/15 15:30:53 END TIME : - DEPLOY ID: : - VIRTUAL MACHINE TEMPLATE NAME=server NIC=[ BRIDGE=vbr1, IP=184.108.40.206, MAC=50:20:20:20:20:20, NETWORK=Public, NETWORK_ID=5 ] NIC=[ BRIDGE=eth0, IP=192.168.0.1, MAC=00:03:c0:a8:00:01, NETWORK=Red LAN, NETWORK_ID=4 ] VMID=12
Now we can query OpenNebula with
onevnet show to find out about given leases and other VN information:
$ onevnet list ID USER NAME TYPE BRIDGE P #LEASES 4 oneadmin Red LAN Ranged vbr0 N 1 5 oneadmin Public Fixed vbr1 Y 1
$ onevnet show 4 VIRTUAL NETWORK 4 INFORMATION ID: : 4 UID: : 0 PUBLIC : N VIRTUAL NETWORK TEMPLATE BRIDGE=eth0 NAME=Red LAN NETWORK_ADDRESS=192.168.0.0 NETWORK_SIZE=C TYPE=RANGED LEASES INFORMATION LEASE=[ IP=192.168.0.1, MAC=00:03:c0:a8:00:01, USED=1, VID=12 ]
Hypervisors can attach a specific MAC address to a virtual network interface, but Virtual Machines need to obtain an IP address. There are a variety of ways to achieve this within OpenNebula:
CONTEXTattribute, check the Contextualization Guide
Please visit the contextualization guide to learn how to configure your Virtual Machines.