Page 1 of 1

NAT and DHCP scope

Posted: 23. Jul 2007, 17:01
by pmotyka
Per the VirtualBox user guide...
The virtual machine receives its network address and configuration on the private network from a DHCP server that is integrated into VirtualBox. The address which the virtual machine receives is usually on a completely different network to the host. As more than one card of a virtual machine can be set up to use NAT networking, the first card is connected to the private network 10.0.2.0, the second card to the network 10.0.3.0 and so on.
The issue I'm having is, the address being assigned to my guest VM is within a subnet that is used on my local network. I need to change this to something like 192.168.0.x. Can the internal DHCP server of VirtualBox be reconfigured?

Posted: 23. Jul 2007, 20:19
by stefan.becker
Look at User doc, setup a network bridge.

Posted: 23. Jul 2007, 20:56
by pmotyka
Thanks for your suggestion. I'm using bridged mode for other VMs, but I'd like to use NAT to avoid consuming too many IPs on my local network. I'm not looking to bridge in this instance, I want to use NAT.

Posted: 23. Jul 2007, 21:39
by stefan.becker
No, that doesnt work.

Posted: 23. Jul 2007, 22:02
by pmotyka
Could you be more specific? NAT is a supported network mode and it seems reasonable to be able to reconfigure the DHCP addressing scope that the internal daemon uses.

NAT is working just fine for my VM right now, I'd just like to change the 10.0.2.x subnet to 192.168.0.x. Are you saying that this is impossible?

Posted: 24. Jul 2007, 00:06
by stefan.becker
Yes.

You can change the NAT interface IP

Posted: 27. Feb 2009, 18:43
by Dean.Rich
This worked great for me.....

From the manual page 126:

9.12 Configuring the address of a NAT network interface

In NAT mode, the guest network interface is assigned to the IPv4 range 10.0.x.0/24 by default where x corresponds to the instance of the NAT interface +2 of that VM.

So x is 2 if there is only once NAT instance active. In that case the guest is assigned to the address 10.0.2.15, the gateway is set to 10.0.2.2 and the name server can be found at 10.0.2.3.

If, for any reason, the NAT network needs to be changed, this can be achieved with the following command:

VBoxManage modifyvm "My VM" -natnet1 "192.168/16"

This command would reserve the network addresses 192.168.0.0 ... 192.168.254.254 for the first NAT network instance of “My VM”. The guest IP would be assigned to 192.168.0.15 and the default gateway could be found at 192.168.0.2.

***Note: Make sure you use the correct capitalization in the VM name. The command is case sensitive.

Re: NAT and DHCP scope

Posted: 9. Sep 2011, 05:36
by amaury
I am using virtualbox 4.0.4 under openSUSE 11.4 with 2.6.37 kernel. I need to use NAT, but i have a problem. The address being assigned to my guest VM is always 10.0.2.15 and I have four Virtual machines with the 10.0.2.15 IP, I have tried to change the range with the command VBoxManage (VBoxManage modifyvm "My VM" -natnet1 "192.168/16") but the problem does not solve, DHCP server that is integrated into VirtualBox assigned to my VMachine always the 192.168.0.15 IP.
Could you help me please?

Data:

operating system:
openSUSE 11.4 x86_64

uname -a
Linux Amaury-VAIO.uci.cu 2.6.37.1-1.2-desktop #1 SMP PREEMPT 2011-02-21 10:34:10 +0100 x86_64 x86_64 x86_64 GNU/Linux

virtualbox version 4.0.4 OSE_r70112

Re: NAT and DHCP scope

Posted: 10. Sep 2011, 04:49
by BillG
I would use a separate vm to act as a NAT router rather than use the built-in NAT. Put your guest machines in an internal network and set up the router vm with one NIC in this network and one bridged to the physical network. You can then use a fully featured router like pfsense and configure it however you like.