IPs assigned by vbox DHCP

Discussions about using Linux guests in VirtualBox.
Post Reply
jam78zen
Posts: 8
Joined: 6. Apr 2018, 20:50

IPs assigned by vbox DHCP

Post by jam78zen »

I've been using static IP addresses, in my /etc/hosts, for my VMs. I want to switch to using vbox DHCP.

But commands like 'ping [vmname]' can't find the IP address of 'vmname'. So of course I can't ssh between one VM and another, or between any VM and the host system.

What should I do about this? Do I have to use an external DHCP server on my host, in order to get access to the assigned IPs? There seems to be no way to access the ones supplied by VBox.
socratis
Site Moderator
Posts: 27329
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: IPs assigned by vbox DHCP

Post by socratis »

jam78zen wrote:I want to switch to using vbox DHCP.
Why? What's wrong with static IPs that are in your "hosts" file? That's as far as I can tell the easiest way to have your 'vmname' option. Plus you have a handy list of IPs-2-names...

If you go with DHCP, there's no guarantee that you'll get the name resolution you're looking for. I do get to see some VMs (like my OSX VMs), because they advertise it over the network (Bojour/Zeroconf).
jam78zen wrote:Do I have to use an external DHCP server on my host, in order to get access to the assigned IPs?
Will that external DHCP server have a list of IPs-2-vmname? And will that list propagate to your host/guests? Remember that if you use Bridged mode, your VMs are supposed to get their IPs from your LAN DHCP server (your router). Does your router have that capability?
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.
jam78zen
Posts: 8
Joined: 6. Apr 2018, 20:50

Re: IPs assigned by vbox DHCP

Post by jam78zen »

Some further info. Sorry I left this out of the original post:

[1] I'm using host-only networking. Each VM has two virtual nics, one for the vbox NAT mechanics, the other for my host-only setup. Since the NAT provides access to the outer world, the host-only network needs only to support access to the host, and mutual access among the VMs (of which there are about a dozen).

[2] The IP address of the vbox DHCP server itself, I've learned, can provide any of my VMs with access to the host. That is, a command such as
ping [vbox-dhcpserver-IP]
works fine, and
ssh [vbox-dhcp-IP]
can log me onto the host from a VM, so I can write my vmname and ip address to a little file on the host.

[3] That server address is recorded in VirtualBox.xml, under the "ExtraData" heading, in the form
<ExtraDataItem name="HostOnly/vboxnet0/IPAddress" value="192.168.56.1"/>

[4] But I'm still dumbfounded that we have to go through all this nonsense just to get an entirely local ip address.
jam78zen
Posts: 8
Joined: 6. Apr 2018, 20:50

Re: IPs assigned by vbox DHCP

Post by jam78zen »

Socratis asked:
"What's wrong with static IPs that are in your "hosts" file? That's as far as I can tell the easiest way to have your 'vmname' option. Plus you have a handy list of IPs-2-names..."

Well, yes, that's exactly why I used /etc/hosts ever since I first got acquainted with VirtualBox in 2008. From then until now I've had a quite stable corral of VMs; but now I am moving to a more dynamic model, in which I can create them and zap them again at will.

I'm sure you can understand what a PITA a hosts file would be in such a scenario.

I want to be able to create a VM -- most likely by cloning it from one of an inventory of exemplars -- and start using it with an absolute minimum of further configuration work. DHCP frees me from any concern with inventing/assigning IP addresses.
jam78zen
Posts: 8
Joined: 6. Apr 2018, 20:50

Re: [Solved] IPs assigned by vbox DHCP

Post by jam78zen »

The tool I needed to know about was evidently 'arp'. I found it, and read the man page, and am about to write a little script which will run on the host to give me the information I need. Thanks Socratis for pushing me along.
socratis
Site Moderator
Posts: 27329
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: IPs assigned by vbox DHCP

Post by socratis »

jam78zen wrote:Thanks Socratis for pushing me along.
Umm....you're welcome (?) ;)
I don't think I did anything in particular, but if you get that script going, please think about updating the thread, it might help others in the future...
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.
Post Reply