Configuring Vmware ESX Networking via CLI (Part II)

This is a continuation of Configuring Vmware ESX Networking via CLI (Part I). This 2nd Part dealt with Port Group. The material of this blog is taken from

  1. Configuring networking from the ESX service console command line (kb.vmware.com)
  2. New User’s Guide to Configuring VMware ESX Networking via CLI (blog.scottlowe.org)

Portgroup Configurations

1. What is vmware Port Group? For more inforamtion,  you may want to see the Vmware Virtual Networking Concepts (pdf)

2. Creating a Port Group

# esxcfg-vswitch -A <Port Group Name> <vSwitch Name>

3. To set the VLAN ID for a Port Group

# esxcfg-vswitch -v <VLAN ID> -p <Port Group Name> <vSwitch Name>

For example,

# esxcfg-vswitch -v 0 -p “Service Console” vSwitch0

where 0 is the VLAN ID

4. Deleting a Port Group

# esxcfg-vswitch -D <Port Group Name> <vSwitch Name>

Configuring Vmware ESX Networking via CLI (Part I)

2 useful sites for configuring Vmware ESX Networking via CLI. The material of this blog is taken from the 2 website.

  1. Configuring networking from the ESX service console command line (kb.vmware.com)
  2. New User’s Guide to Configuring VMware ESX Networking via CLI (blog.scottlowe.org)

In summary, there are 2 important commands you will need to know

  1. esxcfg-vswitch: (Manipulate vswitch and port)
  2. esxcfg-nics: (View network card)

1. Ensure that your Network Cards is connected

# esxcfg-nics –l
Name PCI Driver Link Speed Duplex Description
vmnic0 06:00.00 tg3 Up 1000Mbps Full Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet
vmnic1 07:00.00 tg3 Up 1000Mbps Full Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet

* In the Link Column “Up” means that the Network Adapter is up and connected.

2. List the current virtual switches

# esxcfg-vswitch –l
Switch Name Num Ports Used Ports Configured Ports Uplinks
vSwitch0 32 3 32 vmnic0

PortGroup Name Internal ID VLAN ID Used Ports Uplinks
VM Network portgroup2 0 0 vmnic0

3. Creating a new switch

# esxcfg-vswitch –a <vSwitch Name>

4.  Create the Service Console portgroup on this new virtual switch

# esxcfg-vswitch -A <Port Group Name> <vSwitch Name>

For example,

# esxcfg-vswitch –A “Service Console” vSwitch1

5. To Link the Physcial Switch to a vSwitch

# esxcfg-vswitch -L <Physical NIC> <vSwitch Name>

For example,

# esxcfg-vswitch –L vmnic0 vSwitch1

6. To unlink the the Physcial Switch to a vSwitch

# esxcfg-vswitch -U <Physical NIC> <vSwitch Name>

7. Verify the new virtual switch configuration

# esxcfg-vswitch –l

8. Delete a vSwitch

# esxcfg-vswitch -d <vSwitch Name>

Installing Linux Kernal-Based Virtual Machine (KVM) on CentOS 5.4 Server (Part II)

This is a continuation from Installing Linux Kernal-Based Virtual Machine (KVM) on CentOS 5.4 Server (Part I)

Step 8: Prepare the Virtual Machine

Prepare a Installation Script for easier management.

a. For CentOS Virtual Machine

# vim kvm_centos5.4.sh
virt-install \
--connect qemu:///system \
--name centos5.4_n01 \
--vcpus=2 \
--ram 1024 \
--disk path=/nfs_shared/vms/centos5.4_n01.img,size=40, \
--cdrom=/nfs_shared/ISO/CentOS-5.4-x86_64-bin-DVD.iso \
--network=bridge:br0 \
--accelerate \
--vnc \
--noautoconsole \
--os-type=linux \
--os-variant=rhel5.4 \
--hvm

b. For Windows XP Machine

# vim kvm_winXp.sh
virt-install \
--connect qemu:///system \
--name winxp_n01 \
--vcpus=1 \
--ram 1024 \
--disk path=/nfs_shared/vms/winxp_n01.img,size=25, \
--cdrom=/nfs_shared/ISO/Windows_XP2.iso \
--network=bridge:br0 \
--accelerate \
--vnc \
--noautoconsole \
--os-type=windows \
--os-variant=winxp \
--hvm

Some notes:

  • Do note that the disk path should be on a shared drive if you are planning to use “migration” from physical nodes to another physical node.
  • noautoconsole -> No connection to it is started by default although you can make a connection to it via virt-manager.
  • accelerate -> The VM will runin using kernel acceleration if available.
  • os-type and os-variant -> Please check the man virt-install for more information on the exact paramters.

Step 9: Run the script

You should see something like this

Starting install...
Creating storage file...                                 |  40 GB     00:00
Creating domain...                                       |    0 B     00:01
Domain installation still in progress. You can reconnect to
the console to complete the installation process.

Step 10: Continue the installation through Virt-Manager Console.

Remember to start the libvert daemon first

# service libvertd start

If you are on the graphical console, just type

# virt-manager

you should be able to see the node name. double-clicked the node icon, you should be able to continue the rest of the installation

Installing Linux Kernal-Based Virtual Machine (KVM) on CentOS 5.4 Server (Part I)

Taken from the KVM main site:

Linux Kernel-Based Virtual Machine (KVM) is a full virtualisation solution for Linux on x86 hardware containing virtualization extension (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. KVM also requires a modified QEMU although work is underway to get the required changes upstream. 

This guide is modified from the article from Howtoforge – “Virtualization With KVM On A CentOS 5.2 Server”  and IBM – Quick Start Guide for installing and running KVM. But we will be installing Virt-Manager on the CentOS. I hope to put in additional  note for us to consider as well. Similarly, the this write-up draw information from  

Step 1. Set SELINUX to “disabled”

# vim /etc/selinux/config
SELINUX=disabled

Step 2: Check that hardware support hardware virtualisation

# egrep '(vmx|svm)' --color=always /proc/cpuinfo

Your output should be something like this

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush
dts acpi mmx fxsr sse sse2 ss ht tm syscall nx pdpe1gb rdtscp lm constant_tsc nonstop_tsc pni monitor
ds_cpl vmx smx est tm2 cx16 xtpr popcnt lahf_lm
.......

If you do not get this output, then we can conclude that your hardware does not support virtualisation

Before you do a yum, make sure you  have EPEL Repository enabled. For more information see Red Hat Enterprise Linux / CentOS Linux Enable EPEL (Extra Packages for Enterprise Linux) Repository

Step 3: Install the KVM and virtinst (tools to create virtual machines)

yum install kvm kmod-kvm qemu libvirt python-virtinst

Reboot the System

# shutdown -r now

Step 4: Verify that the kernel has is loaded

# lsmod | grep kvm

the output should be something like

kvm_amd               50452  0
kvm                   109264  1 kvm_intel

Check that the KVM is installed

# virsh -c qemu:///system list
Id Name                 State
----------------------------------

Step 5: Setting up of a Network Bridge so that the VM can be accessed from other hosts on the same network

a. Install the Bridge

# yum install bridge-utils

b. Configure the Bridge. Create the “bridge configuration file”. Ensure the BOOTPROTO, BROADCAST, IPADDR, NETMASK and NETWORK are the same as /etc/sysconfig/network-scripts

# vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
BROADCAST=192.168.50.255
IPADDR=192.168.50.100
NETMASK=255.255.255.0
NETWORK=192.168.50.0
ONBOOT=yes

c. Modify the /etc/sysconfig/network-scripts/ifcfg-eth0. Amend as follows

# Chelsio Communications Inc T310 10GbE Single Port Adapter
DEVICE=eth0
#BOOTPROTO=static
HWADDR=00:xx:00:xx:00:xx
ONBOOT=yes
BRIDGE=br0
#IPADDR=192.168.50.100
#NETWORK=192.168.50.0
#NETMASK=255.255.255.0

d. Disable NetworkManager

# chkconfig NetworkManager off
# service NetworkManager stop
# chkconfig network on

e. Restart the Network

# service network start

f. Verify that the Network Bridge is working

# ifconfig
br0       Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.50.100  Bcast:192.168.50.255  Mask:255.255.255.0
          inet6 addr: fe80::210:a7ff:fe05:afeb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1160 (1.1 KiB)  TX bytes:14875 (14.5 KiB)

eth0      Link encap:Ethernet  HWaddr yy:yy:yy:yy:yy:yy
          inet6 addr: fe80::210:a7ff:fe05:afeb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:13662 errors:7 dropped:160 overruns:4 frame:0
          TX packets:11646 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15144608 (14.4 MiB)  TX bytes:1379942 (1.3 MiB)
          Interrupt:74 Base address:0xcc00

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:38 errors:0 dropped:0 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:4308 (4.2 KiB)  TX bytes:4308 (4.2 KiB)

virbr0    Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:9987 (9.7 KiB)

Step 6: Installing Virt-Manager on CentOS on a remote or local server

# yum install virt-manager
================================================================================
 Package           Arch     Version                             Repository
                                                                           Size
================================================================================
Installing:
 virt-manager      x86_64   0.6.1-12.el5                        base      1.5 M
Installing for dependencies:
 e4fsprogs-libs    x86_64   1.41.9-3.el5                        base      104 k
 gnome-python2-gnomekeyring
                   x86_64   2.16.0-3.el5                        base       17 k
 gtk-vnc           x86_64   0.3.8-3.el5                         base       81 k
 gtk-vnc-python    x86_64   0.3.8-3.el5                         base       12 k
 libvirt           x86_64   0.6.3-33.el5_5.3                    updates   2.0 M
 libvirt-python    x86_64   0.6.3-33.el5_5.3                    updates   137 k
 python-virtinst   noarch   0.400.3-9.el5_5.1                   updates   380 k
 xen-libs          x86_64   3.0.3-105.el5_5.5                   updates   156 k
 xz-libs           x86_64   4.999.9-0.3.beta.20091007git.el5    base       95 k

Transaction Summary
================================================================================
Install      10 Package(s)
Upgrade       0 Package(s)

Total download size: 4.5 M
Is this ok [y/N]:

Step 7: Install Virtual Machines using virt-install

a. Do put an ISO of the Operating System into Server so that you can build the Virtual Machine From. If you only have the disk but not the ISO, you may want to look at “Making Disc Images using mkisofs” from Linux Toolkit

b. Do also take a look at the Guest Support Status from KVM to know what is supported for the version of KVM.

Continuation……
Installing Linux Kernal-Based Virtual Machine (KVM) on CentOS 5.4 Server (Part II)