3

I have a dedicated server with Ubuntu 13.10 installed and a basic installation with Virtualbox and phpvirtualbox to manage the guest OSs on it. I have two IP addresses pointing to the server and I would like to use one of them purely for a virtual OS I have with Ubuntu 12.04 on it.

This means that every port etc. would pass through the host server and be forwarded straight on to this guest OS.

I have looked at the different network methods on VirtualBox but none seem to be for me.

If I use NAT and port forwarding I can set the guest PC to only register calls to those ports through that 2nd IP which is great. However I cant use any standard ports that already are in use on the host PC like SSH or 80 as the host PC uses them on both IPs

How can I get the host OS to just pass everything through to a specific guest OS for a specific IP?

Have I done this wrong and I need to use a different hosting type?

EDIT:

From research and comments it seems bridging should be the way forward but again i am stuck, here is my /etc/network/interfaces file..

# Loopback device:
auto lo
iface lo inet loopback

# device: eth0
auto  eth0
iface eth0 inet static
  address   1.2.3.4
  broadcast 1.2.3.5
  netmask   255.255.255.200
  gateway   1.2.3.1
  # default route to access subnet
  up route add -net 1.2.3.6 netmask 255.255.255.220 gw 1.2.3.1 eth0

iface eth0 inet6 static
  address 2a01:4f8:161:9442::2
  netmask 64
  gateway fe80::1

  #create bridge using additional IP
  auto br1
    iface br1 inet static
    address 2.3.4.5
    netmask 255.255.255.220
    gateway 2.3.4.1
    broadcast 2.3.4.7
    bridge_ports br1 vbox0 vbox1

The server is a Hetzner EX with an additional IP thats on the same MAC address (i can get a different MAC from them if needs be?)

With the above settings i set my Win7 guest OS to be bridged to br1 and set the ip in windows to be static with the same settings i.e.

address 2.3.4.5
netmask 255.255.255.220
gateway 2.3.4.1

But it couldnt pick up a network

Lastly i have added to /etc/vbox/interfaces:

vbox0 vbox br1
vbox1 vbox br1
1

3 Answers 3

1

After a LOT of trial and error, this seems to be the most reliable option...

http://wiki.hetzner.de/index.php/Netzkonfiguration_Debian/en#Bridged

Bridged With a bridged configuration, packets are sent directly. The guest system behaves as if independent. As this makes the MAC addresses of the guest system visible from the outside, a virtual MAC address needs to be requested via the Hetzner Robot and assigned to the guest network card. The bridge gets the same network configuration as eth0. The configuration of eth0 is omitted without replacement.

Get seperate MAC addresses for each of the additional IPs

Then use this for the hosts /etc/network/interfaces..

# remove or disable configuration for eth0
#auto eth0
#iface eth0 inet static
#
auto  br0
iface br0 inet static
 address (Main IP)
 netmask (like eth0, e.g: 255.255.255.254)
 gateway (same as that for the main IP)
 bridge_ports eth0
 bridge_stp off
 bridge_fd 1
 bridge_hello 2
 bridge_maxage 12

Set up the Guest OS in virtualbox to use a bridged network and select br0, then in advanced settings set the mac of the network adapter to the MAC address that Hetzner gave you for the new IP (without any :)

Then in the Guest OS use this..

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
#iface eth0 inet dhcp

iface eth0 inet static
address (ADD IP 1)
broadcast (FOR ADD IP 1)
netmask (FOR ADD IP 1)
gateway (MAIN IP)
dns-nameservers 8.8.8.8
0

Remove the IP address from the host then assign the very same address to the guest on a bridged interface.

2
  • Is my setup correct (added above) for a bridged interface though? If i add a win7 guest os and then attach that to br1, then set the ip address manually to "2.3.4.5" etc then it says IP address conflict??
    – fiscme
    Jan 27, 2014 at 13:14
  • There is nothing to configure on the Linux networking side. Everything is handled by VirtualBox. (answer updated with a link to the documentation).
    – jlliagre
    Jan 27, 2014 at 16:27
0

I followed these instructions with little initial success - br0 wouldn't come up on my Hetzner box.

I found the solution was:

sudo apt-get install bridge-utils
brctl addbr br0

You may also need to remove the default entry in /etc/udev/rules.d/70-persistent.net.rules ,

Of course you should see what Mac address has been allocated to you by Hetzner (in the Robot) and then:

VBoxManage modifyvm <VMName> --macaddress1 xxxxxxxxxx

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .