How to set static IP with VBoxManage - intnet

This is for discussing general topics about how to use VirtualBox.
Post Reply
cremefraiche
Posts: 2
Joined: 19. Jan 2016, 03:30

How to set static IP with VBoxManage - intnet

Post by cremefraiche »

I have searched the forums and read through all of the documentation I could find online and could not find the answer.

I am trying assign a static IP to a VM I am placing on an intnet using only the command line.
The command I am using so far for setting up the network is:

Code: Select all

VBoxManage modifyvm XP-SP3-1.1 --nic1 intnet --cableconnected1 on --intnet test1
But this does not specify an IP/netmask.
I can make this work with `VBoxManage dhcpserver`, but I'd rather know how to do it the right way.
Any help is greatly appreciated.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to set static IP with VBoxManage - intnet

Post by Perryg »

I have never tried it so I can't say that it is even possible, but the only thing that might have a chance is "VBoxManage guestcontrol" since you are trying to modify values inside the guest.
See the users manual for the proper syntax.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to set static IP with VBoxManage - intnet

Post by scottgus1 »

I agree with Perry. All the guests I have installed, various flavors of Windows and a few Linuxes, default to looking for an IP address from the network via the network's DHCP server. You have to be inside the guest to tell it to change to a static IP address with an appropriate subnet mask and gateway.

You could restrict the network's DHCP range to be just one IP address wide, I'd suppose. Then the guest would have a known IP address, but that would reduce the effectiveness of the network rather substantially.

Develop a script that makes the changes for the guest you're planning to use, then deploy that script using the tool for the guest that allows running things in the OS from remote computers, or with Perry's suggestion Vboxmanage guestcontrol. The script can be modified on the host and copied into the guest. See it all in the manual, section 8.31.
cremefraiche
Posts: 2
Joined: 19. Jan 2016, 03:30

Re: How to set static IP with VBoxManage - intnet

Post by cremefraiche »

Thank you both for the reply.

For the project I am working on, restricting DHCP range should get me by.
I haven't used guestcontrol yet, but it looks like the answer I'm looking for.

Now I have to figure out the best way to automagically include GuestAdditions in the install.
Ideally I would like to be able to run a script that automates the OS installation, software install, and finally uses guestcontrol to set the static IP.
I don't have any experience preseeding windows installs, but I think I might be able to fully automate with a tool like nLite (or a linux equivalent if I can find one).
If anyone has experience with this, I'm all ears.
Thanks again.
Post Reply