NAT and DHCP scope

This is for discussing general topics about how to use VirtualBox.
Post Reply
pmotyka
Posts: 3
Joined: 23. Jul 2007, 16:53

NAT and DHCP scope

Post 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?
stefan.becker
Volunteer
Posts: 7639
Joined: 7. Jun 2007, 21:53

Post by stefan.becker »

Look at User doc, setup a network bridge.
pmotyka
Posts: 3
Joined: 23. Jul 2007, 16:53

Post 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.
stefan.becker
Volunteer
Posts: 7639
Joined: 7. Jun 2007, 21:53

Post by stefan.becker »

No, that doesnt work.
pmotyka
Posts: 3
Joined: 23. Jul 2007, 16:53

Post 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?
stefan.becker
Volunteer
Posts: 7639
Joined: 7. Jun 2007, 21:53

Post by stefan.becker »

Yes.
Dean.Rich
Posts: 2
Joined: 27. Feb 2009, 18:35

You can change the NAT interface IP

Post 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.
amaury
Posts: 5
Joined: 9. Sep 2011, 05:18
Primary OS: openSUSE
VBox Version: OSE other
Guest OSses: Ubuntu

Re: NAT and DHCP scope

Post 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
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: NAT and DHCP scope

Post 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.
Bill
Post Reply