Page 1 of 1

Ubuntu Server Guest static IP address using NAT

Posted: 21. Jul 2010, 20:34
by shift
Hey folks,

I'm trying to setup a small Ubuntu Server 10.4 behind NAT connection to use static IP address instead of DHCP
VBox automagically allocated using it's DHCP an IP of 10.0.2.15, however I wish to use a static one, due to my own private reasons,
therefore I've ran the following commands

Code: Select all

ifconfig eth0 down
ifconfig eth0 10.0.2.1 netmask 255.255.255.0 broadcast 10.0.2.255 up 
but didn't seem to have much luck, when trying to ping my home router (10.0.0.138) says that the network is unreachable ,
pinging localhost works fine and so does 10.0.2.1 but nothing further than that.
however, when using dhcp everything work fine.

Just to note, my home (host boxes), are on 10.0.0.0/24, and when I'm trying to ping the guest machine from my host machine I get a request timed out

What am I doing wrong that VBox does better ?

Re: Ubuntu Server Guest static IP address using NAT

Posted: 21. Jul 2010, 23:55
by Sasquatch
The 10.0.2.15 address is a 'hard coded' address. If you set any other address, it will fail. Why do you want to change it anyway? VB provides NAT, just like your modem/router does. So if you want to access the VM, you have to forward ports in it's VM configuration before your other computers can access it.

If you want to have the Guest directly on your network so you can use a static address, while having internet at the same time, use Bridged.

Re: Ubuntu Server Guest static IP address using NAT

Posted: 22. Jul 2010, 08:36
by shift
Hey Sasquatch,

I'm trying to setup a small cluster using two virtual-machines, the reason I picked NAT was due to the fact
that I wanted access to the VM locally and remotely (out of my own private network), and other irrelevant reasons

I've also tried setting up another VM (using NAT ) and got the same IP address, this is one of the reasons why I wanted to use a static IP address

What sort of changes must I do in order to allow/setup static IP address to work ?

Should I use bridged-networking if I want to make the access the VM remotely ?

Thanks in advance.

Re: Ubuntu Server Guest static IP address using NAT

Posted: 22. Jul 2010, 08:46
by fixedwheel
that I wanted access to the VM locally and remotely (out of my own private network),
thats not what VBox NAT is made for: you can reach outside world from your virtual machine but you can not reach the virtual machine out of your private net (outside world in terms of VBox NAT) without using VBox port-forwarding rules.

bridged is what you want

Re: Ubuntu Server Guest static IP address using NAT

Posted: 22. Jul 2010, 21:26
by Sasquatch
shift wrote:the reason I picked NAT was due to the fact that I wanted access to the VM locally and remotely (out of my own private network), and other irrelevant reasons.
I've also tried setting up another VM (using NAT ) and got the same IP address, this is one of the reasons why I wanted to use a static IP address
Won't work. VMs set to NAT are isolated machines. This isn't VMWare. Forget everything they do, grab the manual, read chapter 6 and learn how VB works with networking.

Re: Ubuntu Server Guest static IP address using NAT

Posted: 23. Jul 2010, 18:14
by ChipMcK
refer to http://forums.virtualbox.org/viewtopic.php?f=1&t=29990

so,

...

Bridged or 2nd adapter

Re: Ubuntu Server Guest static IP address using NAT

Posted: 7. Nov 2010, 15:53
by oliver_e
Thank you Sasquatch!
Took me 2 hours until I read your post... Sometimes it's just too easy :D