How to get the IP address used by a Parallels VM from the host?

sorin picture sorin · Jul 27, 2013 · Viewed 8.5k times · Source

Parallels has a command line API which is documented here

>prlctl list
UUID                                    STATUS       IP_ADDR         NAME
{ca50aac6-caa6-47a6-9bfe-e38f6261cb8d}  running      -               win7

Still, even with this the IP_ADDR reported is always empty, even if the machine is running as has an internet connection.

How can I find the IP of the machine from the guest? I need a way to connect to the guest, by using a domain name or an IP.

Answer

JKubecki picture JKubecki · Dec 7, 2013

If it's a Windows VM, you can get the IP with the following command from the host:

prlctl exec "VM Name" ipconfig | grep "IPv4" | grep -o '\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}'

For a *nix VM:

prlctl exec "VM Name" ifconfig eth1 | grep "inet " | grep -o 'addr:\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}' | grep -o '\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}\.\d\{1,3\}'