Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a VirtualBox (v4.1.8) VM that is automatically assigned with an IP in the 10.0.x.x range via DHCP.

Can I change it to use the 192.168.x.x range instead?

share|improve this question

migrated from serverfault.com Mar 8 '12 at 15:46

This question came from our site for professional system and network administrators.

    
Could someone enlighten me as to why I'm getting a downvote? It may be a beginner question, but I am a beginner with VirtualBox and I had to google a fair bit to get to the answer, which is: VBoxManage modifyvm "NameOfVM" --natnet1 "192.168/16" –  RelaXNow Mar 8 '12 at 13:43
    
Then post that as the answer, and you can accept it –  ekaj Mar 8 '12 at 13:44
    
I can't, not enough rep, have to wait a day... if you could post it I could accept and the next guy will have an easier time :). –  RelaXNow Mar 8 '12 at 13:46
2  
It's a tradeoff...encouraging feedback through voting, or require reasons and questions don't get downvotes. Personally I think it's a little rude not to leave a reason, as it doesn't enlighten users to better hone question skills or ask questions appropriate to the community, but that's my opinion. –  Bart Silverstrim Mar 8 '12 at 14:14
1  
May be those who downvoted were questioning the fact this DHCP address was conflicting with your intranet assuming there should be no routing but NAT between the latter and the internal network used by VirtualBox. –  jlliagre Mar 8 '12 at 15:00
show 4 more comments

4 Answers

up vote 10 down vote accepted

Thanks to @RelaXNow, here is the answer to the question:

VBoxManage modifyvm  "NameOfVM" --natnet1 "192.168/16" 
share|improve this answer
1  
Which should be ran on the host machine, not the VM (it wasn't obvious to me from the start) –  periklis Jan 30 at 11:50
add comment

Providing I have understood the question, if you check chapter 6 of the manual it says:

In the VirtualBox graphical user interface, you can configure all these items in the global settings via "File" -> "Settings" -> "Network", which lists all host-only networks which are presently in use. Click on the network name and then on the "Edit" button to the right, and you can modify the adapter and DHCP settings.

enter image description here

share|improve this answer
    
Good answer thanks for the pic, I read the doc too, but I kept going to the specific machine settings not the "general" settings! –  SSH This Jan 18 '13 at 17:50
add comment

Yes it can be changed. There is documentation on it here:

http://www.virtualbox.org/manual/ch08.html#vboxmanage-dhcpserver

It's handled through the VBoxManage dhcpserver command.

share|improve this answer
add comment

You usually don't need to modify VirtualBox DHCP address range. This network is internal and only exists between your VM and the VirtualBox application. There is no routing involved but just NAT.

Should you want to allow accessing your virtual machine from the outside while staying in the default NAT mode, it is possible to selectively open ports (port forwarding).

For example, to allow access to your internal ssh server through the 2022 port, use this command:

VBoxManage modifyvm "NameOfVM" --natpf1 "guestssh,tcp,,2022,,22"
share|improve this answer
    
Yes, but weird things can happen if your host doesn't know how to route to the VM. I had this problem with Vagrant taking 5 minutes to mount the shared folder. I could ping google from the VM, but I couldn't ping anything on the local net. –  rox0r Oct 17 '13 at 2:37
    
@rox0r I don't get what you mean. There is no routing involved from the host to the VM when NAT is used. From the outside, the VM is simply using the host address. –  jlliagre Oct 17 '13 at 4:11
    
Yeah, but the VM will not route back out the default gateway if it thinks the destination is on its subnet. Ie: if the VM is 10.0.2.15/24 and you try to ping 10.0.2.10 which is on the Host's subnet, it will not try to route through the NAT gateway. The same is true if you involve port-forwarding and the connecting machine is 10.0.2.10. The packages will route to the VM but they'll never route back out. –  rox0r Oct 17 '13 at 22:03
    
Got it. Having the same subnet both internally and externally would be a very bogus configuration indeed. –  jlliagre Oct 18 '13 at 9:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.