Steps to Get MAC Address from VMs in ESXi

From Notes_Wiki

Home > VMWare platform > VMWare vSphere or ESXi > Steps to Get MAC Address from VMs in ESXi

Steps to Get MAC Address from VMs in ESXi

This guide explains how to retrieve the MAC addresses of Virtual Machines (VMs) running on an ESXi host.

Step 1: Connect to ESXi Host via SSH

Use any SSH client (e.g., PuTTY) to connect to your ESXi host:

ssh root@<ESXi-IP>

Replace <ESXi-IP> with the IP address of your ESXi host.

Step 2: Run the Command

Run the following single command to list all VMs and their MAC addresses:

for w in $(esxcli network vm list | awk 'NR>1 {print $1}'); do name=$(esxcli network vm list | awk -v wid=$w '$1==wid {print $2}'); mac=$(esxcli network vm port list -w $w | awk '/MAC Address/ {print $3}'); printf "%-30s %s\n" "$name" "$mac"; done

Example Output

Ubuntu-Server                00:50:56:AA:BB:CC
Windows-2022                 00:50:56:11:22:33
Kali-Lab                     00:0C:29:9F:88:77

Notes

  • Works for both powered-on and powered-off VMs.
  • Each VM may have multiple MAC addresses if multiple NICs are configured.
  • Output is displayed in a clean tabular format with VM name and MAC address.


Home > VMWare platform > VMWare vSphere or ESXi > Steps to Get MAC Address from VMs in ESXi