Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am not sure where to post this question whether at programmers.stackoverflow.com or here. So please forgive this if i am at the wrong place.

My question is:

  1. How to set Subnet Mask , DNS address and Gateway address of network adapter inside a virtual machine in Hyper-V programmatically via WMI and C#?

I am working on a Hyper-V provisioning system.

Note: I am successfully able to add and retireve IP Address as described here and here

share|improve this question

1 Answer 1

Lots of people have the mistaken impression that a VM is somehow different from a physical machine with respect to networking configuration. There are differences, but they're almost all explained by noting that the VM is connected to a "software switch" which, in the case of Hyper-V, is just like the unmanaged thing you might plug into your office Ethernet tap, allowing you to use several other machines in your office. Think of the VM host machine like your office. Think of the VMs like the machines in your office. That Linksys (or whatever) box in the corner is the VM switch. The tap in the wall is your host's physical port. (Your host probably has more than one physical port. Imagine an office with more than one tap.)

So how do you set the subnet mask and gateway address of the machines in your office? Do you use some office management interface? No, you go to the machines and set them. (Actually, most people use DHCP for this. You might want to do that, too.) Manage the software configuration of the VMs from within the VMs. (Or use some automatic management suite like System Center.)

Now, of course, it doesn't matter if you put in the right gateway address and such if you attach the VM NIC to the wrong network. In my analogy, this amounts to making sure that your machine is plugged into the right tap in your office. This is something that is managed outside the VM.

share|improve this answer
    
Thanks for the detailed response Jake, but my question was more of a programmatic nature then of configuration management. My goal is to set the IP addressses, gateway and subent mask, Hyper-V WMI API provides kvpdataexchange components that allows to to pull and modify a lot of VM information including Network addresses. See blogs.msdn.com/b/taylorb/archive/2008/05/06/… However, i was unable to find anything useful for pulling and modifying subnet, gateway and dns server addresses programmatically. –  Steve Johnson Jul 19 '11 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.