Dump list of DHCPServer assignments

Here you can provide suggestions on how to improve the product, website, etc.
Post Reply
goyuix
Posts: 2
Joined: 27. May 2016, 17:36

Dump list of DHCPServer assignments

Post by goyuix »

I was poking around VBoxManage and the IDHCPServer API to see if there was a way to show the internal assignment table for the DHCP server. It doesn't look like it is currently exposed. In short, this started as an exercise in trying to determine the IP address for a guest that does not have the additions installed. Using the showvminfo command I can see the MAC address assigned to the adapter, and if I could see the DHCP assignment tables I could pair the information together.

I was thinking something like this:

Code: Select all

VBoxManage dhcpserver     showleaseinfo 
                          [--netname <network_name>]
And the output could look something like this:

Code: Select all

NetworkName: HostInterfaceNetworking-VirtualBox
Lease UUID: {dc89a7bc-da87-486b-9358-5e2094b23a59}
Lease Obtained: 2016-05-27 10:11:12.1234
Lease Expires: 2016-05-28 10:11:12.1234
Lease Physical Address Assignment: 10:11:12:AA:BB:CC
Lease IPv4 Address: 10.0.0.100
Lease IPv4 Subnet: 10.0.0.1
...
I welcome any additional thoughts or questions on this idea, even just encouragement to dust off some C/C++ and see if I could code something up. Thanks!
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: Dump list of DHCPServer assignments

Post by socratis »

Believe it or not, something like that used to be available. I don't know when or why that changed, but here is a sample from an old backup that I have. There were several files that seemed to do what you want located in my 'Library/VirtualBox' directory (that's where the VirtualBox.xml file resides as well):

Host-Only (note that I've changed the default 192.168.56.x range)

Code: Select all

<?xml version="1.0"?>
<Leases version="1.0">
  <Lease mac="08:00:27:fc:40:3c" network="0.0.0.0">
    <Address value="192.168.100.111"/>
    <Time issued="333806117" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:44:24:b5" network="0.0.0.0">
    <Address value="192.168.100.113"/>
    <Time issued="181602038" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:10:30:0f" network="0.0.0.0">
    <Address value="192.168.100.114"/>
    <Time issued="184568451" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:a6:d6:34" network="0.0.0.0">
    <Address value="192.168.100.112"/>
    <Time issued="520509918" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:90:06:9d" network="0.0.0.0">
    <Address value="192.168.100.115"/>
    <Time issued="61457410" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:40:51:1a" network="0.0.0.0">
    <Address value="192.168.100.117"/>
    <Time issued="330225840" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:27:7c:d3" network="0.0.0.0">
    <Address value="192.168.100.116"/>
    <Time issued="355638495" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:5a:7f:77" network="0.0.0.0">
    <Address value="192.168.100.119"/>
    <Time issued="355409791" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:e7:6e:1d" network="0.0.0.0">
    <Address value="192.168.100.122"/>
    <Time issued="326798435" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:92:f0:bd" network="0.0.0.0">
    <Address value="192.168.100.123"/>
    <Time issued="327328033" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:1c:0c:53" network="0.0.0.0">
    <Address value="192.168.100.124"/>
    <Time issued="329624919" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:dc:6b:28" network="0.0.0.0">
    <Address value="192.168.100.118"/>
    <Time issued="356055226" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:43:b3:0b" network="0.0.0.0">
    <Address value="192.168.100.120"/>
    <Time issued="331124886" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:30:a1:d4" network="0.0.0.0">
    <Address value="192.168.100.126"/>
    <Time issued="332087321" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:19:f5:9c" network="0.0.0.0">
    <Address value="192.168.100.125"/>
    <Time issued="343299343" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:f9:61:54" network="0.0.0.0">
    <Address value="192.168.100.121"/>
    <Time issued="407530487" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:9a:6c:07" network="0.0.0.0">
    <Address value="192.168.100.127"/>
    <Time issued="493852633" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:de:fa:75" network="0.0.0.0">
    <Address value="192.168.100.110"/>
    <Time issued="331541716" expiration="1200"/>
  </Lease>
</Leases>
Internal network

Code: Select all

<?xml version="1.0"?>
<Leases version="1.0">
  <Lease mac="08:00:27:37:4a:ad" network="0.0.0.0">
    <Address value="192.168.50.110"/>
    <Time issued="331542133" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:d0:bf:3e" network="0.0.0.0">
    <Address value="192.168.50.111"/>
    <Time issued="0" expiration="0"/>
  </Lease>
  <Lease mac="08:00:27:7a:7f:97" network="0.0.0.0">
    <Address value="192.168.50.112"/>
    <Time issued="181602037" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:21:a3:0e" network="0.0.0.0">
    <Address value="192.168.50.113"/>
    <Time issued="184568180" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:4b:11:2c" network="0.0.0.0">
    <Address value="192.168.50.114"/>
    <Time issued="356054225" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:c9:d7:07" network="0.0.0.0">
    <Address value="192.168.50.115"/>
    <Time issued="0" expiration="0"/>
  </Lease>
  <Lease mac="08:00:27:ed:cc:87" network="0.0.0.0">
    <Address value="192.168.50.116"/>
    <Time issued="355371182" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:2d:69:9d" network="0.0.0.0">
    <Address value="192.168.50.117"/>
    <Time issued="324575012" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:5a:b6:35" network="0.0.0.0">
    <Address value="192.168.50.120"/>
    <Time issued="330225844" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:25:36:e8" network="0.0.0.0">
    <Address value="192.168.50.118"/>
    <Time issued="343699479" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:d9:1c:26" network="0.0.0.0">
    <Address value="192.168.50.119"/>
    <Time issued="355740887" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:c1:5e:70" network="0.0.0.0">
    <Address value="192.168.50.121"/>
    <Time issued="493664191" expiration="1200"/>
  </Lease>
</Leases>
NAT

Code: Select all

<?xml version="1.0"?>
<Leases version="1.0">
  <Lease mac="08:00:27:e6:3a:35" network="0.0.0.0">
    <Address value="10.0.2.4"/>
    <Time issued="107392733" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:c6:59:d1" network="0.0.0.0">
    <Address value="10.0.2.5"/>
    <Time issued="107327357" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:fb:7e:77" network="0.0.0.0">
    <Address value="10.0.2.6"/>
    <Time issued="137149804" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:f7:05:8e" network="0.0.0.0">
    <Address value="10.0.2.7"/>
    <Time issued="632236654" expiration="1200"/>
  </Lease>
</Leases>
NAT Network

Code: Select all

<?xml version="1.0"?>
<Leases version="1.0">
  <Lease mac="08:00:27:ea:a3:44" network="0.0.0.0">
    <Address value="10.0.10.6"/>
    <Time issued="8412272" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:d4:83:5c" network="0.0.0.0">
    <Address value="10.0.10.7"/>
    <Time issued="11347487" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:9d:eb:65" network="0.0.0.0">
    <Address value="10.0.2.4"/>
    <Time issued="1573115915" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:c6:59:d1" network="0.0.0.0">
    <Address value="10.0.10.4"/>
    <Time issued="1573186795" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:53:f0:61" network="0.0.0.0">
    <Address value="10.0.2.5"/>
    <Time issued="1577118322" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:e6:3a:35" network="0.0.0.0">
    <Address value="10.0.10.5"/>
    <Time issued="1577392779" expiration="1200"/>
  </Lease>
  <Lease mac="08:00:27:66:d4:e4" network="0.0.0.0">
    <Address value="10.0.2.6"/>
    <Time issued="1577224457" expiration="1200"/>
  </Lease>
</Leases>
That behavior also meant (I think) that a guest would pretty much get a reserved IP address, based on the MAC address. I've seen it happening in the past and I believe it is still happening, but I'm not sure about that one...
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.
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: Dump list of DHCPServer assignments

Post by socratis »

OK, I have another clue for you. I believe that this is where the logging is/was taking place. I'm not a C/C++ person, I'm just good at searching ;)
/src/VBox/NetworkServices/DHCP/Config.cpp
or if you want to browse the trunk directly : https://www.virtualbox.org/browser/vbox ... Config.cpp
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.
goyuix
Posts: 2
Joined: 27. May 2016, 17:36

Re: Dump list of DHCPServer assignments

Post by goyuix »

Thanks for the info! This is a great start - from the looks of that source file the DHCP information might still be written out somewhere, though some cursory checking didn't show it in with the VM or in the application data folder for my profile. I'll do some more digging.

I really appreciate the pointer! :D
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: Dump list of DHCPServer assignments

Post by socratis »

No sweat. I run into it some time long ago and when your suggestion came in, it just clicked.
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.
gio_da_sicilia
Posts: 1
Joined: 14. Oct 2021, 08:46

DHCP VBOX SERVER LEASES LIST

Post by gio_da_sicilia »

Is possible in Vbox with vboxmanage dhcpserver to obtain a list of all the active leases of the Virtual box Host only DHCP server?
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Dump list of DHCPServer assignments

Post by fth0 »

No, but you can find the information in a file inside the 10.1.2. Global Settings folder.
Post Reply