I'm using VirtualBox for almost everything so I have a lot of VM's. Normally I create a master guest which is copied in case I need a new environment. Currently I have approx 35-40 machines all bridged and most of them via DHCP.
I would like to verify that each machine has it own unique MAC-address assigned. If I'm correct, the assign MAC-address can be found in .vbox XML config file. In my machine all located in /home/vbox. Is there a script or tool available to list the assigned MAC-addresses so we can check if these are all unique ?
Script to check assigned MAC-addresses in .vbox config
-
socratis
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: Script to check assigned MAC-addresses in .vbox config
Not as a standard feature, no, but you could quickly write one yourself. I don't know your host, but it could be something like:
Thanks for the "idea" BTW, I had never thought of checking that aspect. There were no duplicates among all of my 192 different MACs 
- List the VMs with 'VBoxManage list vms'
- For every VM in that output get the VM info with 'VBoxManage showvminfo'
- Pass that output to 'grep' to look for "MAC"
- Pass that output to 'awk' to print only the MAC address
Code: Select all
IFS=$'\t\n';
for i in `VBoxManage list vms | sort | cut -d'"' -f2`; do
VBoxManage showvminfo "$i" | grep MAC | awk '{print $4}' | cut -d',' -f1
done
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.
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.
-
socratis
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: Script to check assigned MAC-addresses in .vbox config
I added another "layer" of information if you want; the VM's name after the MAC address. You could then open the output with a text editor and search for the duplicates, put it in a spreadsheet and sort them or anything else that you might like:
Sample output:
Code: Select all
IFS=$'\t\n';
for i in `VBoxManage list vms | sort | cut -d'"' -f2`; do
for j in `VBoxManage showvminfo "$i" | grep MAC | awk '{print $4}' | cut -d',' -f1`; do
echo "$j $i";
done
done
080027FB7E77 AndroVM-TPApps 080027E0866C AndroVM-TPApps 08002791F8B3 Android 4.4.4 0800276C8311 Android 4.4.4 0800278BFB55 Android 7.1 080027254047 Android 080027A1664A Android 080027CC978B Android 080027763292 Android 0800274ADFC4 ChromeOS ...
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.
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.
-
myhobby
- Posts: 33
- Joined: 21. Mar 2010, 16:56
- Primary OS: Linux other
- VBox Version: OSE other
- Guest OSses: Windows 10
Re: Script to check assigned MAC-addresses in .vbox config
This is great help... Let my try this and provide some feedback so others can use this also

-
myhobby
- Posts: 33
- Joined: 21. Mar 2010, 16:56
- Primary OS: Linux other
- VBox Version: OSE other
- Guest OSses: Windows 10
Re: Script to check assigned MAC-addresses in .vbox config
Running Clearos 6.7, created a script and made it executable...
and executed as user vbox
This indeed creates an overview of the VM machines and it is clearly what I was looking for.... everything listed in VirtualBox.xml is detailed. Machines manually copied and not in the xml are not listed (which is more than fine).
The only small weird thing that happens is an unexpected entry (red). This machine only exists once in the XML.
Results in:
No clue what is causing this, but it works !
and executed as user vbox
Code: Select all
#!/bin/bash
IFS=$'\t\n';
for i in `VBoxManage list vms | sort | cut -d'"' -f2`; do
for j in `VBoxManage showvminfo "$i" | grep MAC | awk '{print $4}' | cut -d',' -f1`; do
echo "$j $i";
done
done
The only small weird thing that happens is an unexpected entry (red). This machine only exists once in the XML.
080027E7881E FreePBX Visual Dialplan Licensed for FreePBX Visual Dialplan Licensed 080027EFAFF2 Machine - Download
Code: Select all
bash-4.1$ VBoxManage list vms | sort
"FreePBX 14 Home PRD" {2d0cb8ba-26ce-487f-a48c-86c0a0cc35b0}
"FreePBX Praktijk Visual Dialplan Licensed" {71494983-3c29-43ea-ab8c-39fb056fa715}
"Machine - Download" {1d8e0ecf-a271-4d31-971c-0303bcf1a7a8}
etc
etc
Code: Select all
bash-4.1$ VBoxManage showvminfo "FreePBX Praktijk Visual Dialplan Licensed" | grep MAC | awk '{print $4}' Code: Select all
080027E7881E,
for
Last edited by socratis on 5. Jan 2018, 09:35, edited 1 time in total.
Reason: Enclosed the information in [code] tag for better readability
Reason: Enclosed the information in [code] tag for better readability
-
socratis
- Site Moderator
- Posts: 27329
- Joined: 22. Oct 2010, 11:03
- Primary OS: Mac OS X other
- VBox Version: VirtualBox+Oracle ExtPack
- Guest OSses: Win(*>98), Linux*, OSX>10.5
- Location: Greece
Re: Script to check assigned MAC-addresses in .vbox config
It's not about "fine", it's that VirtualBox doesn't have a clue about that VM, it's not registered.myhobby wrote:Machines manually copied and not in the xml are not listed (which is more than fine).
I'm not sure what that means. The only thing I can think of is that there might be something wrong with the VM name. It there maybe a "tab" character in the name which causes the parsing to fail? I have no clue, my bash scripting abilities are minimal.myhobby wrote:This machine only exists once in the XML.
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.
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.