Ubuntu Server Guest static IP address using NAT

Discussions about using Linux guests in VirtualBox.
Post Reply
shift
Posts: 2
Joined: 21. Jul 2010, 20:26
Primary OS: Other
VBox Version: OSE other
Guest OSses: Ubuntu, Gentoo, FreeBSD, etc

Ubuntu Server Guest static IP address using NAT

Post 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 ?
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Ubuntu Server Guest static IP address using NAT

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
shift
Posts: 2
Joined: 21. Jul 2010, 20:26
Primary OS: Other
VBox Version: OSE other
Guest OSses: Ubuntu, Gentoo, FreeBSD, etc

Re: Ubuntu Server Guest static IP address using NAT

Post 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.
fixedwheel
Volunteer
Posts: 1699
Joined: 13. Sep 2008, 02:18

Re: Ubuntu Server Guest static IP address using NAT

Post 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
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Ubuntu Server Guest static IP address using NAT

Post 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.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
ChipMcK
Volunteer
Posts: 1095
Joined: 20. May 2009, 02:17
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, OSX
Location: U S of A

Re: Ubuntu Server Guest static IP address using NAT

Post by ChipMcK »

refer to http://forums.virtualbox.org/viewtopic.php?f=1&t=29990

so,

...

Bridged or 2nd adapter
oliver_e
Posts: 1
Joined: 7. Nov 2010, 15:52
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu, Windows XP, Debian

Re: Ubuntu Server Guest static IP address using NAT

Post by oliver_e »

Thank you Sasquatch!
Took me 2 hours until I read your post... Sometimes it's just too easy :D
Post Reply