[SOLVED] List all interfaces

This is for discussing general topics about how to use VirtualBox.
Post Reply
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

[SOLVED] List all interfaces

Post 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?
Last edited by HarryMan on 4. Jan 2022, 03:15, edited 2 times in total.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: List all interfaces

Post 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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: List all interfaces

Post 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.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: List all interfaces

Post 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?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: List all interfaces

Post 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.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: List all interfaces

Post 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...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: List all interfaces

Post by scottgus1 »

You might find this helpfu, on a Windows host:
Dynamic Windows CMD to run Vboxmanage on all guests
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: List all interfaces

Post 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.
Post Reply