<-- back

VirtualBox get IP of VM (cli)

Here is command to run from CLI to get ifconfig output on guest machine (with ubuntu server):

vboxmanage guestcontrol <vm name> run --exe '/sbin/ifconfig' --username <username> --password <pass>


Make sure GAs are installed on the guest

You can write shell function to simplify the call:

function vbox-get-ip() {
    if [ -z $1 ]; then
       echo "pass VM name"
       return
    fi
    vboxmanage guestcontrol $1 run --exe '/sbin/ifconfig' --username <username> --password <pass>
}


Now just call vbox-get-ip <vm name> and ifconfig output will be shown!

Sure you can execute other commands on the host. Just make sure you pass full path to the binary.


Feel free to contact me for feedback or questions. Find my contacts on About page.