Adding an IP address to a server and dedicating it to a VirtualBox VM

I have a dedicated server, I just ordered a second IP address and don't know the proper way to tie it to a VM that's running on the server.
All the documentation and threads that I find are about routing via the same IP but I want to essentially let the guest have it's own reign of the second IP address so it doesn't conflict with anything running on the host machine.

Everything I've tried so far hasn't been working and any help with this would be appreciated..
Thank you.

You have one network interface but two IP addresses? What distro are you running?

You can temporarily add an address this way (if i remember right)

ip addr add <ipaddress/subnetmask> dev <interface>


ip addr add dev eno1

Youll need to look up the documentation for your disto on perminant settings. In Fedora/RH its under /etc/sysconfig/network-scripts/

1 Like

Yeah, it's a single network interface but two ip addresses. The host is Debian Jessie and the guest is Ubuntu 14.04.

I added it to /etc/network/interfaces like this

auto eth0:0
iface eth0:0 inet static

Though I'm not really sure what to do after this.

Oh so i got this slightly wrong.
You'll need to have a virtual Ethernet interface for the VM in a mode that lets it talk straight to the network bypassing the host (i forget which it is, bridged maybe?). and then setup the IP on the guest as you would normally.

But what is it supposed to be bridging?
I can't have a bridged interface without it actually bridging anything (two other interfaces) or the networking service will fail to start. (I'm probably misunderstanding you)

So do I create an interface with an arbitrary name and then do..say... "bridge_ports eth0 virbr0" in the interfaces config?
And then just point VirtualBox to virbr0 as it's interface?

or do I use br0 as the bridge and then do "bridge_ports eth0 (arbitrary interface)" and let the additional interface just happen on it's own?

I'm not really understanding what you mean, as soon as I try to make a virtual interface and bridge two interfaces with it it just prevents the networking service from starting.

If you're using virtualbox, you can set the VM to bridge mode in the config for that VM. You shouldn't need to manually configure Ethernet bridging, the virtualbox stack should handle it.

It doesn't, the VM does not get a connection.

Also I'm trying to give it a secondary IP rather than having it's traffic go through the main one.

Okay. With bridge mode, the guest would be presented to the same network as the host machine. If you're looking to get a static IP onto that, you'd need to manually configure that on the guest.

Is this a hosted server, or something you have physical access to?

It's a hosted server.

I tried pointing VirtualBox to eth0 and configuring that within the guest and that hasn't been working but I'll double check everything once everything boots back up.

So I add the additional ip as before to the host machine via eth0:0 and then I point VirtualBox to eth0. And then I manually configure the IP in the guest?

If I'm honest, I've never done this with a hosted piece of hardware.

Well, not that I didn't directly control. You might be forced to do NAT, the host may not let you bridge a NIC.

You could ask their support folks?

okay, I'll submit a ticket and see if they get back to me.

Actually they have an article in their knowledge base about this but it literally just says "run this command: ip route add [ip address] dev br0". So I'm kind of expecting them to just send me a link to that, but maybe.

Mind linking me to it?

Okay so I found a bunch of other problems with the networking and dealt with those before I came back to dealing with the VM.
I also updated to VirtualBox 5.1x just in case.

It turns out that I had to request a separate mac address from my host to allow the VM to connect to the network.
But now bridging works as expected.