Proxmox: List all Running VMs with IPs

This shell loop queries Proxmox for the IPv4 addresses of all currently running virtual machines by leveraging the QEMU Guest Agent. It first lists running VMs using qm list, extracts their VMIDs, and then iterates over each one. For every VM, the command qm guest cmd <vmid> network-get-interfaces asks the guest agent inside the VM to report its network interfaces and assigned IP addresses. This approach is reliable because the information is provided directly by the guest operating system rather than inferred from the host or network.

The JSON output from each VM is processed with jq, which may need to be installed on the Proxmox server if it is not already present. The script requires jq version 1.6 or newer, as earlier versions lack features used by the filter. The jq processing filters out the loopback interface (lo), selects only IPv4 addresses, and prints a concise mapping of VMID IP_ADDRESS. This method requires that the QEMU Guest Agent be installed and running inside each VM; without it, Proxmox cannot reliably determine VM IP addresses.

for vmid in $(qm list | awk '$3=="running" {print $1}'); do
qm guest cmd $vmid network-get-interfaces 2>/dev/null | \
jq -r --arg vmid "$vmid" '
.[]
| select(.name != "lo")
| ."ip-addresses"[]
| select(."ip-address-type" == "ipv4")
| "\($vmid) \(.["ip-address"])"
'
done

Sample Output

100 10.10.19.25
101 10.10.19.26
102 10.10.19.27
103 10.10.19.28
104 10.10.19.29
105 10.10.19.30