Assigning static IP of hosted Physical Machine

Discussions related to using VirtualBox on Windows hosts.
Post Reply
keyvisions
Posts: 6
Joined: 11. Apr 2015, 09:15
Primary OS: MS Windows 2008
VBox Version: OSE other
Guest OSses: Windows, Ubuntu
Location: Italy
Contact:

Assigning static IP of hosted Physical Machine

Post by keyvisions »

Hello All,
I've been trying without success to assign one of the static IPs associated to a hosted physical machine to a VirtualBox VM. This is the setup:
1. Hosted Physical Machine with MS Win Server 2008 R2, two NICs only one connected
2. I have 2 static IPs assigned (each in IPv4 and IPv6 format) ( I can have up to 8 )
3. Installed VirtualBox (ver. 4.3.26)
4. Created a Ubuntu server VM
Now, I would simply like to assign one of the static IPs to the Ubuntu VM so that it can be accessed directly from the Internet (it's a test machine)

On the MS Host I assigned the two static IPs to the attached NIC, created the Ubuntu VM and then tried NAT, Bridged, and the latest NAT Network, playing with preferences and settings on the VirtualBox end and the Ubuntu VM end (i.e. /etc/network/interfaces). Watched youtube videos, read documentation and searched forums... I'm missing something, certainly not determination, suggestions are welcomed, the solution, well, desired.
Last edited by keyvisions on 11. Apr 2015, 22:53, edited 1 time in total.
Visualize then Realize
Legorol
Posts: 95
Joined: 11. Mar 2014, 21:40

Re: Assigning static IP of hosted Physical Machine

Post by Legorol »

First, can you please clarify something about your number of IP addresses: you say you "have 2 static IPs assigned (each in IPv4 and IPv6 format)". Generally, IPv4 and IPv6 addresses are independent from each other (unless you are deliberately using one of the standardised IPv4-to-IPv6 mapping schemes). So do you have 4 IP addresses in total (2 IPv4 and 2 IPv6), or do you have 2 IP addresses in total in some variation?

I recommend you first focus on IPv4 alone, which is generally easier to set up. Once that works, worry about IPv6.

With regards to correctly assigning static IPv4 addresses between host and VM: assuming you have 2 static IPv4 addresses, this is how you proceed. Set the VM networking to be Bridged. On the host, statically assign only one of the IPv4 addresses to the NIC. Then, in the guest, statically assign the other IPv4 address to the (virtual) NIC inside the guest.

The way Bridged networking works, it effectively makes the VM behave like a separate physical computer connected to the same LAN. So you configure networking in the host and guest the same way you would configure two separate physical hosts. So you assign one IPv4 address to each.

I think the mistake you are making is that you are assigning both IPv4 addresses to the host's NIC, which is incorrect.
keyvisions
Posts: 6
Joined: 11. Apr 2015, 09:15
Primary OS: MS Windows 2008
VBox Version: OSE other
Guest OSses: Windows, Ubuntu
Location: Italy
Contact:

Re: Assigning static IP of hosted Physical Machine

Post by keyvisions »

To clarify the number of IPs, yes, I should have said 4: the physical machine came with both an assigned IPv4 and an IPv6; when I requested an additional IP I was given another IPv4 and an IPv6 (I assumed they came in pairs :)). Yes, let's concentrate on the IPv4, the new IP x.x.234.159 is not on the same network as the first x.x.146.105, mask 255.255.255.0 and gateway x.x.146.65, for the second IP I have not been given a mask nor a gateway but I suppose the suggested bridge connection will take care of that. I'll test the suggestion and post back.
Last edited by keyvisions on 12. Apr 2015, 07:07, edited 2 times in total.
Visualize then Realize
Legorol
Posts: 95
Joined: 11. Mar 2014, 21:40

Re: Assigning static IP of hosted Physical Machine

Post by Legorol »

keyvisions wrote:.. for the second IP I have not been given a mask nor a gateway but I suppose the suggested bridge connection will take care of that. I'll test the suggestion and post back.
The bridged connection doesn't take care of anything, it behaves exactly as if the VM was a separate physical computer connected to the LAN. You will need subnet mask and gateway information to configure the second static IP address in the VM. You need to ask your ISP for that information.
keyvisions
Posts: 6
Joined: 11. Apr 2015, 09:15
Primary OS: MS Windows 2008
VBox Version: OSE other
Guest OSses: Windows, Ubuntu
Location: Italy
Contact:

Re: Assigning static IP of hosted Physical Machine

Post by keyvisions »

I was told by the ISP to configure the VM NIC mask 255.255.255.255 and use the first IP as the gateway x.x.146.105, fact is that Ubuntu rightly complains that the gateway is not on the same network, so i tried changing the mask to 255.255.0.0, and also setting as the gateway the same as the host NIC x.x.146.65. In these endless combinations I also tried to set the promiscuous mode for the Bridged Adapter, mind you, to avoid dirty setups I reinstalled Ubuntu every time (fortunately it takes 3-4 minutes).
Visualize then Realize
Legorol
Posts: 95
Joined: 11. Mar 2014, 21:40

Re: Assigning static IP of hosted Physical Machine

Post by Legorol »

Unfortunately this is now a networking issue rather than a VirtualBox issue, so it's hard to help you much further. Promiscuous mode for the VM is not necessary for what you are trying to achieve.

I notice that you edited one of your earlier posts and changed mask from 255.255.255.255 to 255.255.255.0. Also, your posts are not entirely clear. Since things are getting a bit confusing, I will summarise my understanding of your situation (concentrating on IPv4). Let me know if any of these details are wrong:

ISP assigned two static IPv4 addresses: x.x.146.105 and x.x.234.159
ISP specified a single external gateway address: x.x.146.65
ISP advised that for x.x.146.105, use the mask 255.255.255.0 and set the gateway to x.x.146.65 (the external gateway).
ISP advised that for x.x.234.159, use the mask 255.255.255.255 and set the gateway to x.x.146.105 (the other static IP of yours).

Based on this, it sounds like your ISP wants you to route traffic from your second IP through your first IP and not send traffic directly to the external gateway. This is a valid scenario, but its configuration may be tricky. Here is some poor ASCII art to try and describe the situation:

Code: Select all

   -------------------
	|    gateway      |
	|  IP x.x.146.65  |
	-------------------
          |
          | LAN
          +-----------------------------------
          |                                  |
  ----------------------         ------------------------
  |     host 1         |         |       host 2         |
  | IP   x.x.146.105   |         | IP   x.x.234.159     |
  | mask 255.255.255.0 |         | mask 255.255.255.255 |
  | gw   x.x.146.65    |         | gw   x.x.146.105     |
  ----------------------         ------------------------
In the case of your VM, using bridged mode effectively results in a LAN configuration as above.

Here are some pointers:
1) It is valid to have a mask of 255.255.255.255. It is allowed to have a static IP of x.x.234.159, a mask of 255.255.255.255 and the gateway set to x.x.146.105. I am not familiar with Ubuntu, so I don't know how to correctly configure it, but even if it complains, at best it should warn you, but not prohibit you from using that setup.

2) You have to configure host 1 to act as a gateway and correctly route traffic for host 2. This involves enabling Routing and Remote Access service in Windows Server 2008 R2, and turning on IP routing. It also involves adding the correct routing information on host 1, namely configuring a static route for the IP x.x.234.159.

It's not an easy setup by any means, but it's valid.
keyvisions
Posts: 6
Joined: 11. Apr 2015, 09:15
Primary OS: MS Windows 2008
VBox Version: OSE other
Guest OSses: Windows, Ubuntu
Location: Italy
Contact:

Re: Assigning static IP of hosted Physical Machine

Post by keyvisions »

Legorol, your poor ASCII art diagram describes my situation exactly. Indeed this has become a networking issue, your first reply was reassuring and sufficent, you clearly indicated the Bridged connection: VirtualBox at that point was out of the equation.

Yes, I did change the mask, my error, I was told to use a final 0 for Microsoft VMs and 255 for Linux VMs, like so:

Code: Select all

==Linux Systems==
Netmask: 255.255.255.255
Gateway: the primary Ip address of your server (x.x.146.105)

==Windows Systems==
Netmask: 255.255.255.0
Gateway: leave empty
BTW, during a clean install of Ubuntu, when Bridged connection is specified, the VM is unable to configure the network automatically and asks for manual intervention, it is during this phase that the system refuses the netmask gateway combination.
In your last post, you point out routing, that's where I'm heading. Thank-you for you valuable replies, I'll post my solution when I find it.
Visualize then Realize
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Assigning static IP of hosted Physical Machine

Post by scottgus1 »

keyvisions, One thing I see as a possibiltity to simplify stuff. Your host has two NICs, one of which is unconnected, right?
1. Hosted Physical Machine with MS Win Server 2008 R2, two NICs only one connected
Can you connect it? If so, uncheck all the Windows bindings on that NIC but leave all the Virtualbox bindings checked, so only Virtualbox can use that NIC. Then the guest can be set to Bridged to that second Virtualbox-only NIC, and all data coming to that NIC goes into the guest without going through the host network arrangement. I'd guess you set the guest's virtual NIC IP address to the desired public IP address within the guest itself, then the guest will get the internet traffic destined for it. (I think...)
keyvisions
Posts: 6
Joined: 11. Apr 2015, 09:15
Primary OS: MS Windows 2008
VBox Version: OSE other
Guest OSses: Windows, Ubuntu
Location: Italy
Contact:

Re: Assigning static IP of hosted Physical Machine

Post by keyvisions »

scottgus1, that's not an option provided by the data center hosting the physical machine. What I'm after is how to assign static IPs to VMs, in my case the hosting service makes it possible but it's clearly not a simple ride as legorol pointed out. Just have to do a bit more homework.
Visualize then Realize
BillG
Volunteer
Posts: 5104
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Assigning static IP of hosted Physical Machine

Post by BillG »

In fact your problem is how to assign static IPs to a Ubuntu machine. As Legorol has made clear, once you have assigned the NIC in your vm to use bridged mode, the process to assign a static IP is identical for virtual or physical machines.

The Ubuntu machine will only auto-configure if it can see a DHCP or NAT server. If it could do that, you would not need to worry about static IPs.

Personally, I would not even attempt to do things that way. I would run RRAS on the Windows Server and run the vms on a private LAN, getting their config from NAT on the RRAS server. I would allocate all of the static IPs not used by the host to an address pool in RRAS and use static mapping to map them to the machines on the LAN as required. No config required on any vm. They will get their private config automatically from NAT.
Bill
keyvisions
Posts: 6
Joined: 11. Apr 2015, 09:15
Primary OS: MS Windows 2008
VBox Version: OSE other
Guest OSses: Windows, Ubuntu
Location: Italy
Contact:

Re: Assigning static IP of hosted Physical Machine

Post by keyvisions »

BillG, indeed your final suggestion RRAS + NAT, a variant of what Legorol alludes, is what I initially wanted to do, but here is the twist, without RRAS. And this brings us back to topic: I created a NAT Network in VirtualBox assigning the new IP x.x.234.159 to network CIDR, then set the Ubuntu VM to use that NAT Network; simple and logical but did not work. Thoughts?

----

That was my narrow minded interpretation the "NAT Network", mind you, not the simple "NAT".
Last edited by keyvisions on 17. Apr 2015, 15:06, edited 2 times in total.
Visualize then Realize
BillG
Volunteer
Posts: 5104
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Assigning static IP of hosted Physical Machine

Post by BillG »

There is no way that could work. You really need to talk to someone who understands how IP routing works.
Bill
Post Reply