Static IP for a VM

Discussion about using the VirtualBox API, Tutorials, Samples.

Static IP for a VM

Postby akjuturub04 » 21. Jun 2013, 03:02

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   Expand viewCollapse view
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.
akjuturub04
 
Posts: 9
Joined: 19. Jun 2013, 23:14

Re: Static IP for a VM

Postby noteirak » 21. Jun 2013, 14:53

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://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: Static IP for a VM

Postby akjuturub04 » 24. Jun 2013, 03:06

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?
akjuturub04
 
Posts: 9
Joined: 19. Jun 2013, 23:14

Re: Static IP for a VM

Postby noteirak » 24. Jun 2013, 10:46

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://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7


Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 1 guest