How to interrogate Host Only DHCP leases

This is for discussing general topics about how to use VirtualBox.
Post Reply
avidscavenger
Posts: 12
Joined: 27. Dec 2015, 00:58

How to interrogate Host Only DHCP leases

Post by avidscavenger »

Hi there,

Can anyone tell me how to interrogate the leases for a DHCP server running on a Host Only network (eg vboxnet0)?

What I want to do is to access my guests by name without having to create static IP's. Ideally i would configure domain resolution so that guests are found by simply using their name, but I'd settle for being able to run a script to find an IP from the guest name.

Thanks!
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to interrogate Host Only DHCP leases

Post by BillG »

That is what DNS is for, not DHCP.
Bill
avidscavenger
Posts: 12
Joined: 27. Dec 2015, 00:58

Re: How to interrogate Host Only DHCP leases

Post by avidscavenger »

Of course it would be nice if the domain server would do the job, but since it is the DHCP that allocates the IPs, the IPs can be retrieved by examining the DHCP leases even without a DNS.
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: How to interrogate Host Only DHCP leases

Post by BillG »

The DHCP server certainly knows about IP addresses but it knows nothing about names. Perhaps you could tell use what you are really trying to do here?

You can certainly run a group of vms as a domain with DHCP and DNS. The best option is to use an internal virtual network. That is how mine runs.
Bill
avidscavenger
Posts: 12
Joined: 27. Dec 2015, 00:58

Re: How to interrogate Host Only DHCP leases

Post by avidscavenger »

Ah OK I had imagined the DHCP server recording hostnames as dhcpd does. If that isn't the case then I guess I am back to square one.

What I want to do is simply avoid having to check the on IP my guests have been assigned before I can access them over a Host Only network. Not only is this procedure a pain in the neck but it's impossible (well maybe not strictly but not easy) to automate because you have to have a connection to your guest before you can ask it what its IP is. Still even if the lease only records the MAC address I could still script something... if I could just work out where those leases are stored. It's a bit confusing why they aren't neatly sitting next to NAT leases which are in ~/.config/VirtualBox/NatNetwork.leases (on Linux/Debian at least).

Setting up a VPN sounds like a sledgejammer to crack a nut to me. My guests do not need to communicate with one another, all i want to do is easily connect to my guests from my host.

Thanks for the replies btw.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: How to interrogate Host Only DHCP leases

Post by Martin »

The default host only network is using the 192.168.56.0/24 subnet. The DHCP server of this network is running on 192.168.50.100 and distributing addresses in the .101-.254 range.
If you can assign static addresses you could use addresses between .10 and .99 (leave the low addresses for Vbox) and you wouldn't need to care about DHCP.
avidscavenger
Posts: 12
Joined: 27. Dec 2015, 00:58

Re: How to interrogate Host Only DHCP leases

Post by avidscavenger »

For what it's worth, my last post gave me an idea - using a standard DHCP server (eg isc-dhcp-server on Debian) instead of Virtualbox's built-in one. All I had to do was disable the DHCP server on Virtualbox's Host-Only networking configuration and configure isc-dhcp-server to work on the vboxnet0 interface. Works perfectly. Also let's me configure extra things like router, DNS server, and all the other goodies that a full-blown DHCP server can do.
Post Reply