Page 1 of 1

[SOLVED] List all interfaces

Posted: 19. Jun 2019, 03:08
by HarryMan
I am hoping that vboxmanage or another existing tool offered this. I would like to list *all* interfaces for all networks created by/for the virtualbox system (as opposed to real or virtual interfaces on the host system that were not created by/for virtualbox), indicating status, whether in use and by which VMs, maybe MAC addresses, and other pertinent information. This would be helpful when trying to analyze certain configurations.

Is there a public API for, say, the virtualbox XML files? Would the information in those files be sufficient to gather all the information re all interfaces?

Re: List all interfaces

Posted: 19. Jun 2019, 10:10
by socratis
I'm not sure I follow the question... Are you asking about the HostOnly and the NATservice NICs? The NICs of the VM? Can you please explain it a little bit further? Obviously all the info is available (AFAIK), I simply don't know which info for you're looking for...

Re: List all interfaces

Posted: 19. Jun 2019, 15:28
by HarryMan
So perhaps I might type something like "VBoxManage list interfaces adapters" and it would spit out, line by line, each interface and the VMs they are attached to, maybe so:

vboxnet0 hostonlyif somelinux-vm:adapter1 anotherlinux-vm:adapter1
vboxnet1 hostonlyif ubuntu:adapter1 elementaryos:adapter2 somelinux-vm:adapter2(*) linux-vm3:adapter1 netbsd-vm:adapter1 alpine-linux-vm:adapter1
intnet1 intnet private-vm1:adapter1 private-vm2:adapter1 somelinux-vm:adapter3
nat1 nat alpine-linux-vm:adapter2
br1 bridge netbsd-vm:adapter2

and so forth. Maybe the "*" means the adapter has no wire attached to it atm. Maybe another option would include MAC addresses in the output, and so on. (I doubt including IP addresses would be practical.) And the output as presented here is just one possible manner in which the information might be presented; there may be a better, more normalized means to presenting the information.

This would be handy when trying to figure out where noise is coming from on a particular network, and perhaps other purposes. It occurs to me that this could be useful for helping to generate a wiring diagram for a complex data center.

I would not think this is very hard to accomplish.

Re: List all interfaces

Posted: 19. Jun 2019, 16:18
by socratis
I had to "reformat" your example in order to understand it better, I'm having a hard time reading terminal output with serif fonts. ;)
Interdace   Kind          VMs:Adapters
-------------------------------------------------------------------------------
vboxnet0    hostonlyif    somelinux-vm:adapter1 anotherlinux-vm:adapter1
vboxnet1    hostonlyif    ubuntu:adapter1 elementaryos:adapter2 somelinux-vm:adapter2(*)
intnet1     intnet        private-vm1:adapter1 private-vm2:adapter1 somelinux-vm:adapter3
nat1        nat           alpine-linux-vm:adapter2
br1         bridge        netbsd-vm:adapter2
For every host physical adapter, and the VirtualBox internal ones (like vboxnet0, intnet1, nat1) which do not show in the host, do a lookup through each VM and post the info "which is attached to what".

Did I get it better this time? Is this something like that you had in mind?

Re: List all interfaces

Posted: 20. Jun 2019, 18:10
by HarryMan
Yeah, I guess I should have hit the "Code" button for my example output (sorry). I was trying to give a general idea of what the output could look like; I wasn't really trying to create a technical spec. At any rate, yes, your nicely formatted output is one possibility.

Thank you for spending the time to discuss this.

Re: List all interfaces

Posted: 4. Jul 2019, 23:09
by socratis
The information is already there, albeit not readily available, you need to do some work...
For each available $VM in "VBoxManage list vms"
  • Do a "VBoxManage showvminfo $VM"
    • Filter for the keyword "NIC" and not "disabled"
      • Grab the output for further parsing
I have a script like that for example that gives me all the MACs for all my VMs, sorted by MAC, just to visually inspect if there's a duplicate in there. I have another script that gives me all the IPs for all the running VMs that use Bridged. Others have other scripts based on their needs. You wouldn't expect VirtualBox to provide such specific outputs, I highly doubt it...

Re: List all interfaces

Posted: 5. Jul 2019, 19:52
by scottgus1
You might find this helpfu, on a Windows host:
Dynamic Windows CMD to run Vboxmanage on all guests

Re: List all interfaces

Posted: 2. Jan 2022, 12:15
by HarryMan
Sorry, I did not follow up with this.

I ended up writing a perl script that parses the xml files and compiles the information in a format that allows me to select and sort by command arguments.