How to find the IP addresses of VMs from vagrant

So what I am looking to do is retrieve the IP address associated with multiple VM’s that I’ve generated from a Vagrantfile.

the basic way is to ssh onto the machine and use ifconfig or ip a. However, what I’ll be doing to automating a series of operations on my host machine, only one of which will be to execute the ‘vagrant up’. The Vagrantfile will be autogenerated based on a series of perimeters. I don’t want to assign static IP addresses, so I need to find a way to get the addresses for the different VM’s that will be generated.

I found one such way of getting the results that I’m looking for via the stackoverflow fourth answer down.

vagrant ssh dcopTest -c "hostname -I | cut -d' ' -f2" 2>/dev/null

This works, I’m just trying to find out if there is a better way?