[Solved] Assign public IP address to VM?

This is for discussing general topics about how to use VirtualBox.
Post Reply
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

[Solved] Assign public IP address to VM?

Post by J2R »

I have a machine at a hosting provider which is running Windows 2008 Server, whose IP address is 83.xxx.xxx.xxx (obviously with real numbers instead of the x's!). I have been given a couple of 'spare' addresses in the range 77.xxx.xx.xxx. What I would like to be able to do is to have a Linux guest VM running certain services, accessible publicly, so I presumed I would set up a bridged adapter in the Windows host, and in Linux configure eth0 with the static address 77.xxx.xx.xxx. Having done this, though, I'm neither able to address the VM from the host nor vice versa. So what is the correct way to do what I want? Thx.
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: Assign public IP address to VM?

Post by Sasquatch »

Just setting an IP address won't get you anywhere. You still need a route to it, so a gateway is needed and it needs to be registered to a DNS server if you want to access it through name instead of IP.
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.
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

Re: Assign public IP address to VM?

Post by J2R »

Sasquatch wrote:Just setting an IP address won't get you anywhere. You still need a route to it, so a gateway is needed and it needs to be registered to a DNS server if you want to access it through name instead of IP.
I set up eth0 in /etc/network/interfaces on the Ubuntu guest with the static IP address but I don't actually know what the gateway should be (I took a guess). Is this likely to be what the issue is? I presume that with a correct gateway in there, the host should be able to find the guest and vice versa, but I'm puzzled about the two entirely different ranges.
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: Assign public IP address to VM?

Post by Sasquatch »

You should have gotten the rest of the IP configuration from your provider that supplied those IP addresses. If it didn't, ask them for it. You would face the same problems as with a native system.
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.
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

Re: Assign public IP address to VM?

Post by J2R »

Sasquatch wrote:You should have gotten the rest of the IP configuration from your provider that supplied those IP addresses. If it didn't, ask them for it. You would face the same problems as with a native system.
Thanks, I'm trying to get that information now. So am I right in thinking that all I should need to do would be to use a bridged adapter and then configure the requisite static IP address information in my Linux VM and it should then be addressable via that public IP address?
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: Assign public IP address to VM?

Post by Sasquatch »

Yes, the same things you did as on the Host to make it internet accessible. Bridged will make it appear like a separate machine on the network.
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.
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

Re: Assign public IP address to VM?

Post by J2R »

Well, the hosting provider got back to me with the answer "You don't actually need a gateway address for these additional IPs." Now, I'll admit I don't know much about networking but this is definitely something I don't get - how can an additional IP, in a different range, not require a gateway address? I did try configuring a static IP address without a gateway in the VM, but once again I couldn't access the network.
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: Assign public IP address to VM?

Post by Sasquatch »

Sounds like they think you add that IP address as second IP on an already configured interface. If they are serious about this for an unconfigured machine, I will wish you good luck, because without a gateway, no OS will know where to send a reply to, the data will just go into a big black hole.
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.
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

Re: Assign public IP address to VM?

Post by J2R »

Sasquatch wrote:Sounds like they think you add that IP address as second IP on an already configured interface. If they are serious about this for an unconfigured machine, I will wish you good luck, because without a gateway, no OS will know where to send a reply to, the data will just go into a big black hole.
Yes, my thoughts exactly. I'll see if I can press them.
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

Re: Assign public IP address to VM?

Post by J2R »

Well, I got a gateway address out of them but I still can't get this working. If I do an ifconfig, I see that my eth0 interface has a large value for TX bytes and 0 for RX bytes. If I try to connect to an IP address on the same network, I get a no route to host error. I tried changing from pcnet to Intel T Server but it has not made a difference. Any tips, please?
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: Assign public IP address to VM?

Post by Sasquatch »

Does the gateway show up in route? You should have a default gateway set in that, like this:

Code: Select all

default         router          0.0.0.0         UG    100    0        0 eth0
You can add the gateway manually through the command line using this:

Code: Select all

route add default gw <ip address>
Having a high TX value only means that a lot of packets have been transmitted, but because RX is 0, no packet ever got received.
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.
J2R
Posts: 82
Joined: 11. Oct 2007, 23:55

Re: Assign public IP address to VM?

Post by J2R »

You know, sometimes I'm so busy trying to be really clever in one area that I don't realise how staggeringly stupid I'm being in another...

I found the problem. I was simply trying to bridge to the wrong adapter, the primary one. As soon as I chose the secondary one (which I hadn't noticed before) the problem went away. Sorry to have wasted your time!
cruzades
Posts: 1
Joined: 18. Mar 2014, 04:31

Re: [Solved] Assign public IP address to VM?

Post by cruzades »

Hi J2R

I'm stumbled with this thread

It is yours, and I have the same issue with yours, I'm hoping that you can able to give a light for this please.

My setup is, Windows 2008 Server hosted.

I have 10 Public IPs available to use for my virtualbox, how ever I can't even get my virtual box and IP from secondary NIC (bridge), my question is do I need to put my Public IP on my Second NIC (host) so that the client (virtualbox) will able to get an IP?

Can I have your setup documentation from your setup?

Regards,
Eric
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: [Solved] Assign public IP address to VM?

Post by mpack »

The post you're commenting on was made in 2009, and J2R has not visited since Dec 2011, so you might wait a long time for his answer...
Post Reply