Home > VMware Tips > VMware management, migration and performance > Modifying a guest's NIC with the VI3 SDK
VMware Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

VMWARE MANAGEMENT, MIGRATION AND PERFORMANCE

Modifying a guest's NIC with the VI3 SDK


Andrew Kutz, contributor
12.20.2007
Rating: --- (out of 5)


Enterprise IT tips and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Network engineers often implement security at Layer 2, turning ports off if a system is misbehaving. For VMware ESX, this practice could be potentially disastrous as many virtual machines (VM) may share a single port. Fortunately, with a little help from a VMware tool, you can avoid this mess and never suffer the wrath of a Layer-2 overkill outage again.

The VMware ESX service console is being retired, so there goes the ability to run scripts locally on an ESX server. That means that the VI3 (VMware Infrastructure 3) Software Developers Kit is about to become a necessity for those who want to interact with ESX programatically. This tip, and others in my SDK series, offers useful ways to leverage the SDK to help make your everyday interaction with ESX/VI3 all the more seamless.

That is why I am writing a series of tips about the VI3 SDK. These tips will focus on useful ways to leverage the SDK to help make your everyday interaction with VI3 all the more seamless. To begin this series I present instructions on how to build a small program that can be used to modify the connection status of a guest's network interface card (NIC). Many organizations' information security and/or networking departments implement security at a Layer-2 level - if they detect an infected machine on the network they will shut off its port. That's fine and dandy when dealing with physical servers, but what about ESX? If a port is shut down then it could potentially shut off access for several virtual machines (VMs), not just the one that is misbehaving. The solution is to produce a tool that can shutdown the network interface of a specific VM. Follow along with me as I present code written in C# that does just that.

If you want to follow along in your integrated development environment (IDE) the complete project is available for download at lostcreations.com. It is a Visual Studio 2005 project.

The code I have written, available for download here, builds on previous examples I have written about the SDK. I will begin my explanation of this program on line 106 of the file Program.cs, but explanations for how I parse the command line options and how I connect to the VI3 SDK Web service are available in my three part introduction to the VI3 SDK: Understanding the VI3 SDK, Leveraging the VI3 SDK with .NET, and Exploring the SDK.

That's all there is to it! The program gnicmod.exe can be executed from the command line in order to alter the connection state of one, or many, guest NICs. An example of its usage and output is as follows:


C:\gnicmod -s vcms.lostcreations.local -l -u akutz -p mypassword -m i: 

192.168.0.111,p:connected,v:true,f:true -m i: 
192.168.0.87,p:connected,v:false,f:false 
+,192.168.0.111,connected,true 
+,192.168.0.87,connected,false 

Network engineers often implement security at Layer 2, turning ports off if a system is misbehaving. For VMware ESX, this practice could be potentially disastrous as many virtual machines (VM) may share a single port. Fortunately, with a little help from a VMware tool, you can avoid this mess and never suffer the wrath of a Layer-2 overkill outage again.

The VMware ESX service console is being retired, so there goes the ability to run scripts locally on an ESX server. That means that the VI3 (Virtual Infrastructure 3) Software Developers Kit is about to become a necessity for those who want to interact with ESX programatically.

This is one of several VI3 SDK tips I'm offering on useful ways to leverage these tools to help make your everyday interaction with ESX/VI3 all the more seamless. In this tip, I give instructions on how to build a small program that can be used to modify the connection status of a guest's network interface card (NIC).

As I said above, many organizations' information security and/or networking departments implement security at a Layer-2 level. If they detect an infected machine on the network, they will shut off its port. That's fine and dandy when dealing with physical servers, but what about ESX? If a port is shut down then, it could potentially shut off access for several virtual machines, not just the one that is misbehaving.

The solution is to produce a tool that can shut down the network interface of a specific VM. Follow along with me as I present code written in C# that does just that.

If you want to follow along in your integrated development environment (IDE), the complete project is available for download on lostcreations.net in a Visual Studio 2005 project.

The following code builds on previous examples I have written about the SDK. I will begin my explanation of this program on line 106 of the file Program.cs, but explanations for how I parse the command-line options and how I connect to the VI3 SDK Web service are available in my three-part introduction to the VI3 SDK.

That's all there is to it! The program gnicmod.exe can be executed from the command line in order to alter the connection state of one, or many, guest NICs. An example of its usage and output is as follows:


C:\gnicmod -s vcms.lostcreations.local -l -u akutz -p mypassword -m i:
192.168.0.111,p:connected,v:true,f:true -m i:
192.168.0.87,p:connected,v:false,f:false
+,192.168.0.111,connected,true
+,192.168.0.87,connected,false

If you have any questions about this program, or the VI3 SDK in general, feel free to contact me via editor@searchvmware.com.

Andrew Kutz is deeply embedded in the dark, dangerous world of virtualization. Andrew is an avid fan of .NET, open source, Terminal Services, coding and comics. He is a Microsoft Certified Solutions Developer (MCSD), a SANS/GIAC Certified Windows Security Administrator (GCWN) and a VMware Certified Professional (VCP) in VI3. Andrew graduated from the University of Texas at Austin with a BA in Ancient History and Classical Civilization and currently lives in Austin with his wife Mandy and their two puppies, Lucy and CJ.

Rate this Tip
To rate tips, you must be a member of SearchVMware.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



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.

HomeNewsTopicsITKnowledge ExchangeTipsBlogsMultimediaWhite PapersEvents
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2007 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts