18

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.

sorin
  • 161,544
  • 178
  • 535
  • 806
  • 4
    Unfortunately `prlctl` is now a Pro-only feature... – Lars Bilke Nov 23 '15 at 11:48
  • @LarsBilke which means more reasons to scrap Parallels for VirtualBox, even if is clearly not so cool but is clearly more than OK for 9/10 users. – sorin Nov 23 '15 at 11:55

3 Answers3

16

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\}'
JKubecki
  • 579
  • 5
  • 8
  • 5
    This answer should start with "If Parallels Tools are installed on the guest..." "exec" command only works with guest with the Tools installed. – hshib Jan 31 '15 at 16:52
  • wow, with this I don't even need to know the ip address to ssh to the VM remotely, as I can just run the commands directly - which is a good thing if ssh/telnet connections are being rejected. – Michael Jan 19 '17 at 00:01
  • Great. Now to figure out why it's got a default address which suggests it didn't DHCP properly... – Michael Oct 01 '18 at 14:04
  • 1
    This is the message I get when I run your script: "The command is available only in Parallels Desktop for Mac Pro or Business Edition." – prmph Mar 25 '19 at 11:17
14

I stumbled upon this today and found it questionable that the list command shows an IP_ADDR but never the IP. I checked the most recent docs for the prlctl command and its states:

-f, --full

Shows the real IP address(es) for running virtual machines.

Providing this flag displays the IP addresses for me

prlctl list -f

Community
  • 1
  • 1
Larusso
  • 1,121
  • 8
  • 10
12

if you want to access the machine using SSH there is a built in command that can help with this.

prlctl enter <VM_ID|VM_NAME>

This will open a prompt as root to the VM if you want the IP for any other reason there is another way to get it

prlctl exec <VM_ID|VM_NAME> ifconfig

The exec command from prlctl will execute the ifconfig command on the host linux machine (if using windows do ipconfig instead of ifconfig)

All the output of the ifconfig will be printed on your terminal and the ip will be clearly visible in the output

yshahin
  • 146
  • 4
  • Using "enter" for SSH is definitely the way to go. Thanks! – kwcto Mar 26 '14 at 21:28
  • I've been looking for this exact feature for days now. Thank you! – Adriano C R Jul 22 '14 at 15:51
  • This answer should start with "If Parallels Tools are installed on the guest..." Both "enter" and "exec" command only works with guest with the Tools installed. – hshib Jan 31 '15 at 16:53
  • Also, "prlctl enter" is not SSH. It seems to be connecting to the console directly, even bypassing the authentication via parallels own protocol. – hshib Jan 31 '15 at 17:00
  • Putting an example here: `prlctl exec 'Windows 10' ipconfig | grep IP` where "Windows 10" is the name of my windows VM as shown in `prlctl list`. – Raghu Dodda Jun 06 '21 at 00:26