Page 1 of 1

Nat router (network) in VirtualBox 4.3

Posted: 27. Oct 2013, 17:22
by unbalanced
Hey guys.

I'm using Ubuntu 13.04 as the guest (on win7 host). This Virtualbox is used as a web server for development.
Until now i had 2 network adapters - Host Only + Nat.

1. Using VB 4.3, i switched the 2 adapters with the new "Nat Network" adapter. is this OK? does it suppose to save the hassle and complex of having 2 adapters?

2. How can i configure the /etc/network/interfaces file on ubuntu so that the dev server will have a static ip (10.0.2.4)
- i want to use port forwarding from host specifically to that guest and i don't want to get different internal ip each time i boot it.

3. Using the "Nat Network" port forwarding, can i forward port 80 from 127.0.0.1 to port 80 on the ubuntu server (10.0.2.4 virtualbox) in order to allow other computers on my office wifi see the website on my development server?

Really appreciating the help here :)
Thanks!

Re: Nat router (network) in VirtualBox 4.3

Posted: 28. Oct 2013, 01:32
by BillG
Is there a reason why you don't use bridged mode so that the other machines on the LAN could see the server directly? That seems the obvious way to me.

Re: Nat router (network) in VirtualBox 4.3

Posted: 28. Oct 2013, 09:34
by unbalanced
It has to do with the hosts file settings on other machines on the net. though your approach will work (tried it in the past)
i'd still love to know if anyone knows the answers for the above!

Thanks BillG :)

Re: Nat router (network) in VirtualBox 4.3

Posted: 29. Oct 2013, 01:22
by BillG
Yes, it should work but it requires a fair bit of work. I haven't tested it fully yet, but I hope to in the near future.

Re: Nat router (network) in VirtualBox 4.3

Posted: 29. Oct 2013, 10:57
by unbalanced
Can anyone tell me how to setup a static ip to each virtual machine under the nat network adapter, Thanks!

Re: Nat router (network) in VirtualBox 4.3

Posted: 29. Oct 2013, 23:25
by noteirak
Have you tried setting up the IP in the VM itself, like you would do it on physical machine? does it work?

Re: Nat router (network) in VirtualBox 4.3

Posted: 30. Oct 2013, 06:10
by BillG
Why would it be any different just because you are using a NAT network?

Or was your question really "how do I manually configure the network settings for a machine using NAT network"?

The answer to that question is - look at the config you get from DHCP and make sure that everything is exactly the same, apart from the actual IP address.

Re: Nat router (network) in VirtualBox 4.3

Posted: 30. Oct 2013, 10:39
by unbalanced
i tried using the following settings on etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.0.2.4
netmask 255.255.255.0
network 10.0.2.0
broadcast 10.0.2.255
gateway 10.0.2.2
my nat network is configured: 10.0.2.0/24 and the "support dhcp" is checked.

Couldn't get the connection to work.
Guys I'm really appreciating your responses, thanks!

Re: Nat router (network) in VirtualBox 4.3

Posted: 31. Oct 2013, 06:09
by BillG
Well that should work if you are in a 10.0.2.0/24 network (ie a network with addresses beginning 10.0.2 and a subnet mask of 255.255.255.0) and a gateway of 10.0.2.2 . Does it work if you get the config from DHCP? What does the config look like then?

I have had a good look at it now and NAT networking works just as advertised for me (even with static IPs). I have set up a Windows domain with static IP on the DC and DHCP for the clients without problems (apart from the standard DNS oddities with NAT and AD).

Here is a check list I would use.
1. Carefully read the manual section on NAT networking.
2. Configure your internal network using a addressing scheme you will remember and enable DHCP. If in doubt use the example from the manual.
3. Set the NIC in the vm to the NAT networking option. Boot the vm.
4. Check that the vm gets an IP from DHCP and that you can access LAN machines from the vm. If you want to make it static, use exactly the same settings as it got from DHCP. Everything should be the same except the last octet of the IP address (ie the machine identifier in the subnet) which you can change.
5. Configure port forwarding in NAT to forward http from the host to the LAN IP of the guest. If you do it properly, an http request from a LAN machine to the host (by name or IP) will get a reply from the webserver in the vm.