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

3

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.

Delineator answered 27/7, 2013 at 10:54 Comment(2)
Unfortunately prlctl is now a Pro-only feature...Ludly
@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.Delineator
H
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\}'
Hadden answered 7/12, 2013 at 18:56 Comment(4)
This answer should start with "If Parallels Tools are installed on the guest..." "exec" command only works with guest with the Tools installed.Crain
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.Mixup
Great. Now to figure out why it's got a default address which suggests it didn't DHCP properly...Mixup
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."Daven
S
15

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

Stanfield answered 26/11, 2019 at 13:38 Comment(0)
C
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

Cardiff answered 20/8, 2013 at 23:55 Comment(5)
Using "enter" for SSH is definitely the way to go. Thanks!Barbie
I've been looking for this exact feature for days now. Thank you!Georgiannegeorgic
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.Crain
Also, "prlctl enter" is not SSH. It seems to be connecting to the console directly, even bypassing the authentication via parallels own protocol.Crain
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.Valvular

© 2022 - 2024 — McMap. All rights reserved.