Wednesday, October 1, 2008

ESX network configuration automation with esxcfg-vswitch

ESX network configuration automation with esxcfg-vswitch

For VI3 environments with multiple VLANs, configuration accuracy is an important step in providing virtual machines with the correct connectivity. Using the esxcfg-vswitch ESX host commands can make life as a VMware admin easier, but there’s a lot to learn. Lucky for you, I have taken the time to familiarize myself with the esxcfg-vswitch ESX host series of commands and have documented them for quick network configuration recreation. A word of caution, however; esxcfg-vswitch is an interactive command and if you are experimenting, you should work with a host in maintenance mode to avoid causing an interruption to your live workload.

In describing how to use the esxcfg-vswitch command, I want to first explain some practice points that I use in my VI3 environment. Most importantly, I create a virtual switch exclusively for the service console and VMkernel (VMotion) roles, and a separate virtual switch for all of the guest virtual machine port groups. The port groups on this separate virtual switch will have 802.1Q VLAN tags applied. With that, let’s jump into the command.

One of the first things you can do is inspect the current virtual switch configuration. This is done with the following command:

esxcfg-vswitch -l

The result will be something similar to what is shown below:

To recreate networks, we can use the esxcfg-vswitch to do this task. My preference is to remove the existing virtual switch, and re-create it to expected configuration. Here is a sample script that will first remove and then re-create the entire virtual switch and five port groups with their corresponding VLAN identifiers:

esxcfg-vswitch -d MainGuestVirtualSwitch

esxcfg-vswitch -a MainGuestVirtualSwitch

esxcfg-vswitch –link=vmnic3 MainGuestVirtualSwitch

esxcfg-vswitch –link=vmnic4 MainGuestVirtualSwitch

esxcfg-vswitch –add-pg=PrivateNetwork MainGuestVirtualSwitch

esxcfg-vswitch –add-pg=ShopFloor MainGuestVirtualSwitch

esxcfg-vswitch –add-pg=BackBuildingUpper MainGuestVirtualSwitch

esxcfg-vswitch –add-pg=BackBuildingLower MainGuestVirtualSwitch

esxcfg-vswitch –add-pg=CoreCorporate MainGuestVirtualSwitch

esxcfg-vswitch –vlan=334 –pg=PrivateNetwork MainGuestVirtualSwitch

esxcfg-vswitch –vlan=332 –pg=ShopFloor MainGuestVirtualSwitch

esxcfg-vswitch –vlan=236 –pg=BackBuildingUpper MainGuestVirtualSwitch

esxcfg-vswitch –vlan=237 –pg=BackBuildingLower MainGuestVirtualSwitch

esxcfg-vswitch –vlan=100 –pg=CoreCorporate MainGuestVirtualSwitch

A couple of notes on this: MainGuestVirtualSwitch is the name for the virtual switch instead off the default vSwitch1 (remember the first one - vSwitch0 - is for service console and VMkernel). There are two interfaces available to this virtual switch, vmnic3 and vmnic4. The port group names are the friendly names of the networks that are used in VI3. After running this script, the following will immediately appear in the networking configuration section of the host in the VMware Infrastructure Client:

clip_image001

I usually go into the virtual switch after it is created through script to make both interfaces active, instead of the default scripted result of one as active and subsequent vmnic interfaces as standby. Good information on esxcfg-vswitch is a little light, but VMworld 2006 had a couple of mentions of it and virtualization expert Mike Laverick makes some mentions of esxcfg-vswitch on the RTFM site.

Saturday, September 27, 2008

Political war between Marathon and VMware on Fault Tolerance Feature of VMware.

Political war between Marathon and VMware on Fault Tolerance Feature of VMware.

A great political debate has been started on VMWare fault tolerance feature during
VMWare world meet at LA 2008. A four reason listed by Marathon has draw sharp criticism from VMware lover. Please read the complete story here. One of the four reason listed for short fall of VMWare FT is listed as ========================Snip==================================


2. Complexity on top of complexity. In order to use VMware Fault Tolerance, you’ll first have to install both VMware HA and DRS. No small feat in and of themselves. Then, because VMware FT requires NIC teaming, you’ll also have to manually install paired NICs. Then you’ll need to manually setup dual storage controllers (with the software to manage them) because it requires multi-pathing. And to top it all off, you’re required to use an expensive, and often complicated, SAN.

========================Snip====================================


To this Mike has given a great response on his blog and responded how easy HA and DRS to configure

=========================snip==================================


See those two check boxes? Click them and you've just enabled HA and DRS. If that's
too hard then please comment and let me know how it could possibly be easier. Even my dog has figure out how to do this now. Granted, it's a pretty smart dog.

=======================snip=====================================

What a response… Well Q is if you want to sell you product sell it ,but please do not do some cheap marketing. Where VMwaer is right now MS or any other will take ages to reach and I am ready to bet on my word

DAMN you Microsoft







Friday, September 26, 2008

How To Rename The Host and Change IP address

How To Rename The Host and Change IP address




Sometimes host has to be renamed or IP address has to be changed. Please follow these steps.

  1. Change the name under

[root@xxxxxx root]# more /etc/sysconfig/network-scripts/ifcfg-vswif0

DEVICE=vswif0


MACADDR=00:50:56:4f:65:19


PORTGROUP="Service Console"


BOOTPROTO=static


BROADCAST=xx.xx.xx.255


IPADDR=xx.xx.xx.xx


NETMASK=255.255.255.0


ONBOOT=yes

  1. [root@xxxx root]# more /etc/sysconfig/network

NETWORKING=yes


HOSTNAME=<Full DNS Name>


GATEWAY=XX.XX.XX.XX


GATEWAYDEV=vswif0

3. [root@xxxxxx root]# more /etc/hosts


# Do not remove the following line, or various programs


# that require network functionality will fail.


127.0.0.1 localhost.localdomain localhost


xx.xx.xx.xx %FQDN Name of the host% %NetBIOS name%


Best would be reboot the host.

How to Rename Service Console

I was given task to build the system and then I started building it. It is not that I don’t know how to perform ESX build and believe me each hardware and every environment is different. Person has to go through these experiences as they explore the environment.

I build a new ESX box (DL 380) and then gave everything default. I choose a default VLAN for service console. When machine came back online it is not able to ping the default gateway. I started trouble shooting and starting to figure out how to make sure that if NIC are getting trunked on correct VLAN. To find out this one I used

“esxcfg-nics -l” . This will list us which NIC is up. Now the challenge was if the correct NIC is listening to the “Service Console”. To find out this one I used “esxcfg-vswitch -l” This will show the VLAN ID as well as which NIC is it is configured for.

clip_image002

Here you can see that “vmnic1” is “UP ” but “Service Console ” is configured for “vmnic0” . So here I have to basically swap the cable and bring “vmnic0” or change service console to listen to “vmnic1”. Easier would be swap the cable and then label the “service console” to listen to appropriate VLAN. Right now “Service Console ” is set to VLAN 0. To change the VLAN label use following “ esxcfg-vswitch –v <vlan id> -p “Service Conole” vSwitch0 ” (Command in the fist quotes should be run).

I did that and that fixed the network.