Static IP for a VM

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
akjuturub04
Posts: 9
Joined: 19. Jun 2013, 23:14

Static IP for a VM

Post by akjuturub04 »

Hi,

I am working on Virtual Box SDK and I have a couple of questions. Any of your suggestions would be helpful.

1. When ever I start a VM, I need to get the IP address from DHCP for the first time, but upon subsequent restarts, I want the VMs to get the same IP address. Is it possible to do programatically using the SDK? Can you please point me to the specific class/function calls?

2. Where can I get the documentation for "VirtualBoxManager" class used in TestVBox.java . The SDK reference guide provides documentation for "IVirtualBox" and all but not for "VirtualBoxManager" class. Here is how it is used in TestVBox.java

Code: Select all

VirtualBoxManager mgr = VirtualBoxManager.createInstance(null);
IVirtualBox vbox = mgr.getVBox();
 mgr.startVm(m, null, 7000);


My Setup information:
Virtual box and API version: Version 4.2.12
Connection Type: object-oriented web service (OOWS)
Language: Java
Host OS: Windows 7 64

Thanks.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Static IP for a VM

Post by noteirak »

1) that is not possible directly, as Virtualbox is a hardware emulator. IP is already "software level". What you could do is use the guest execute. See IProcess, IGuestSession, IGuest, IConsole & IMachine
2) IVirtualBoxClient is the interface you're looking for.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
akjuturub04
Posts: 9
Joined: 19. Jun 2013, 23:14

Re: Static IP for a VM

Post by akjuturub04 »

noteirak wrote:1) that is not possible directly, as Virtualbox is a hardware emulator. IP is already "software level". What you could do is use the guest execute. See IProcess, IGuestSession, IGuest, IConsole & IMachine
2) IVirtualBoxClient is the interface you're looking for.
Hi noteirak,

Thanks for the reply. If not programatically, can I configure VirtualBox so that VMs get same IP address every time?
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Static IP for a VM

Post by noteirak »

No you can't. IPs are OS configuration level, where Virtualbox is hardware.
What you can do is run some command in the guest using the interfaces I gave you, then you could configure the guest OS for a specific IP.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply