Get list of VMs using a specific network interface

JRace

New Member
Nov 1, 2023
1
0
1
Is there a way to get a list of VMs using a specific network interface?
For example, in the VMWare vCenter GUI, you can click on a virtual network switch and get a list of all VMs that are using it.
I'm trying to get a handle on what VMs might be configured with one particular interface without having to go through each one and look at the network adapter config.
 
I don't think that there is a way to see them in the GUI.

Since every VM has a config file under /etc/pve/qemu-server you could grep them for the parts that marks the interface connected to a certain bridge, like so:
Code:
cd /etc/pve/qemu-server
grep 'bridge=vmbr0' *
 
Cluster wide search, with a bit more bells and wistles:

Code:
for vmid in $(grep -l vmbr2 /etc/pve/nodes/*/qemu-server/*.conf | sed -e's/.*\///;s/.conf//');do echo -n "$vmid: ";grep ^name: /etc/pve/nodes/*/qemu-server/${vmid}.conf|cut -d\  -f2;done|sort -k2

for vmid in $( grep -l vmbr2 /etc/pve/nodes/*/qemu-server/*.conf | sed -e's/.*\///;s/.conf//');
#              ^-- get config file matching interface              ^-- extract vmid from file name
do
  # display vmid / vm name (extrzcted from config file)
  echo -n "$vmid: ";
  grep ^name: /etc/pve/nodes/*/qemu-server/${vmid}.conf | cut -d\  -f2;
done | sort -k2
#      ^ -- sort result
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!