Home > ESX, ESXi, VI, VMware > List IP Addresses used in WMWare ESX

List IP Addresses used in WMWare ESX

April 22nd, 2009

How to extract the IP addresses in use by the Guests in our VMware ESX host?
This was the question that I asked myself yesterday, when I had to go over a long list of IPs and check if any of the listed IPs was in use by any Guest Operating system on our ESX server. I immediately thought of the VMware VI Toolkit and all the nice commands that I have seen there, but none of those came to me immediately. A colleague was swifter and used python to get any matches after he copied all IPs manually using the Infrastructure Client, but since I had few spare minutes today, I decided to solve this one and post the answer. Here it is:

[VI Toolkit] C:\Program Files\VMware\Infrastructure\VIToolkitForWindows> get-vmg
uest -vm (get-vm *) |select IPAddress

IPAddress
———
{192.168.128.110}
{192.168.128.113}
{}
{192.168.128.127}
{}
{}
{192.168.128.125}
{}
{}
{192.168.128.175}
{}
{}
{}
{}
{192.168.128.186}
{192.168.128.153, 192.168.128.163, 10.10.128.153}
{}
{192.168.128.154, 192.168.128.164, 10.10.128.154}
{192.168.128.102}
{192.168.128.196}
{192.168.128.236}
{192.168.128.213}
{192.168.128.103}
{192.168.128.254}

The bad thing about it is that powered off machines are not declaring their IP addresses in use, instead they list only an empty dictionary {}, so these have to be checked manually by powering On the machine. My logic was that we don’t use those that were powered off at that point so I was satisfied with the partial answer of the question.

Of course you could customize the view of the output by adding an additional column to the IP addresses. That’s in case you would like to know which HostName is using the IP address or how much RAM is allocated to that guest OS.

I am getting more and more interested in automating my daily tasks using the VMware VI Toolkit. It proves to be a powerful administration tool.

Categories: ESX, ESXi, VI, VMware Tags: , , ,
Comments are closed.