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

Is there a way to find out, using Win2008 R2 Hyper-V manager or a command-line tool, the externally-accessible IP Address(es) of Windows XP Hyper-V guests?

I'd like to be able to connect to my guests by IP address via Remote Desktop (for cases where name resolution is not working properly) but without combing through the DHCP server it's been challenging to know which IP address corresponds to which host.

Any ideas?

Assigning static IPs to each guest is possible but is something I'd like to avoid.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

look at this link it will do what you want

http://blogs.technet.com/b/m2/archive/2010/07/29/how-to-get-the-ip-address-of-a-virtual-machine-from-hyper-v.aspx

share|improve this answer
    
+1, Learn something new every day. –  Chris S Aug 6 '10 at 17:37
    
obviously me too since this was just posted on the technet blogs! –  tony roth Aug 6 '10 at 20:12
add comment

Why not just use the Hyper-V Manager to open the VM's Console? It works remotely if you have Remote Management enabled in the Firewall Settings, and you don't have to do any look-ups in the DHCP Server. Otherwise, no, Hyper-V does not track it's VMs IPs, just their MAC addresses.

share|improve this answer
    
I'm having a separate problem where the video for local connections to VMs is not working correctly, and I haven't had time to figure out how to fix it. So I've been relying on remote desktop to connect directly to clients until I can fix the console issue. Since I'll know the MAC address, is there a good way to map from MAC to IP? –  Justin Grant Aug 5 '10 at 19:02
1  
Using the DHCP Server's list of leases is the most reliable way. The ARP table on the hyper-v host might have the IP as well, though it could just as easily not. –  Chris S Aug 5 '10 at 19:32
add comment

You could use a script to get the information from WMI (from technet):

...determine the IP address of a computer?

Use the Win32_NetworkAdapterConfiguration class and check the value of the IPAddress property. This is returned as an array, so use a For-Each loop to get the value. strComputer = "."

Set objWMIService = GetObject( _ 
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
    ("Select IPAddress from Win32_NetworkAdapterConfiguration ")

For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then 
        For i=LBound(IPConfig.IPAddress) _
            to UBound(IPConfig.IPAddress)
                WScript.Echo IPConfig.IPAddress(i)
        Next
    End If
Next

Sadly that's code for the local machine, and you'd need to tweak it according to this article to connect to the remote WMI.

It might just be easier to have each machine write its IP address to a text file on a network share when it starts up.

Or you could query the DHCP server directly for the information (if it's MS, http://serverfault.com/questions/110864/can-i-query-dhcp-server-for-getting-mapping-of-mac-to-ip-address-i-have-admin-ri should work)

share|improve this answer
    
hi Kara - unfortunately I'd need to know the IP address to connect to WMI. And it's an ISP-provided router, not a Microsoft DHCP server, so that option won't work. Next I am going to try screen-scraping the DHCP page on the router's web-based control panel. –  Justin Grant Aug 16 '10 at 3:59
    
Aw dang, it had looked like the script was using the hostname to get the IP from the DHCP server, but I could've misread. Looks like Tony's answer should do it though? –  Kara Marfia Aug 16 '10 at 12:35
add comment

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.