3

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.

Justin Grant
  • 259
  • 1
  • 4
  • 12

3 Answers3

5

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

tony roth
  • 3,844
  • 17
  • 14
1

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.

Chris S
  • 77,337
  • 11
  • 120
  • 212
  • 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 05 '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 05 '10 at 19:32
0

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, Can I query DHCP server for getting mapping of MAC to IP address (I have admin rights)? should work)

Kara Marfia
  • 7,892
  • 5
  • 32
  • 56
  • 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 03: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