Multi static IPs, 1 NIC, bridged to multi static guest IPs

Discussions related to using VirtualBox on Linux hosts.
Post Reply
quackking
Posts: 19
Joined: 11. Jun 2007, 16:38

Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by quackking »

Here's the use case:

In short, Virtualbox 3.12 Multiple static IPs on one (Ubuntu 9.10) host NIC bridged to multiple static IPs in guests.

That is, I have a single physical box in a hosting environment with multiple public internet address available. I want to run several public IPs through the single physical NIC on the box (not hard in a non-bridged environment, simply use eth0:0, eth0:1, etc aliases..) but I want to 'pipe' one IP (all ports) to VM1, a second to VM2, etc. and of course I want the host machine to respond to ssh, vnc, etc on its own IP. I don't care that if guest A tries to ping guest B on the public internet, the traffic goes all the way back to the ISP..not an issue for me. However, that should work if both guests have 'piped' public IP addresses.

How to do this?

Does the syntax br0:0 work? If so, that is likely to be the solution.

eg., put something like this into /etc/interfaces

IP0 -> br0:0 -> eth0 -> vbox0 ;
IP1 -> br0:1 -> eth1 -> vbox1 etc..

or perhaps
IP0 -> br0:0 -> eth0:0 -> vbox0 ;
IP1 -> br0:1 -> eth0:1 -> vbox1

Note, the system presently works with one public static IP for the bridge, and two guests with static 10.1.10.x addresses, but of course those guests cannot be seen outside of the host. Those guests can ping each other, and the host can ping each of them on the 10.x address.

Now I want to add more public IPs to the host (again, if I can specify aliases for br0 like br0:0, br0:1, etc., I think that would do it) - and then map each of the virtual NICs to a single, permanent (not dynamically assigned) guest.

Help?
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by Sasquatch »

You can give the Guests it's own external IP. There is no need for a manual bridge. That was before 2.1.0, where TAP devices were used. Now you simply tell the VM to use a physical NIC for bridged, configure the Guest with the IP you want it to have and presto, it should work.
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.
quackking
Posts: 19
Joined: 11. Jun 2007, 16:38

Re: Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by quackking »

The Host /etc//network/interfaces file presently looks like this:

(xxx below refers to a real value, of course..)

Code: Select all


auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
	address 75.xxx.xxx.100
	netmask 255.255.255.240
	gateway 75.xxx.xxx.xxx
# auto br0:0
# iface br0:0 inet static
# 	address 75.xxx.xxx.103
# 	netmask 255.255.255.240
# 	gateway 75.xxx.xxx.xxx
# auto br0:1
# iface br0:1 inet static
# 	address 75.xxx.xxx.105
# 	netmask 255.255.255.240
# 	gateway 75.xxx.xxx.xxx
	post-up iptables-restore < /etc/iptables.up.rules

If I enable the commented area, the network will not start on the host.

How do I bind the NIC on the host to three public IP addresses at startup?

What am I doing wrong?

The /etc/network/interfaces file on Guest A looks like this right now (Guest B will be similar, with a different public IP):

Code: Select all


# The loopback network interface
auto lo
iface lo inet loopback

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

iface eth0 inet static
    address 10.1.10.54
    netmask 255.255.255.0
    gateway 10.1.10.1

# iface eth0:0 inet static
#   address 75.xxx.xxx.103
#   netmask 255.255.255.0
#    gateway 75.xxx.xxx.xxx
#    post-up iptables-restore < /etc/iptables.up.rules

Are you saying it should look like this ?

Code: Select all


iface eth0 inet static
   address 75.x44.xxx.xxx
   netmask 255.255.255.0
   gateway 75.144.155.110
Remember, I don't want the host to respond to any traffic meant for either guest.

Thanks in advance for your help!
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by Perryg »

I think you are making this more difficult than it needs to be.
Just assign one public address to each guest in bridged mode and be done with it.

Example. ( use what ever the real addresses are)

75.xxx.xxx.102 -> host
75.xxx.xxx.103 -> guest 1
75.xxx.xxx.104 -> guest 2
75.xxx.xxx.105 -> guest 3
quackking
Posts: 19
Joined: 11. Jun 2007, 16:38

Re: Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by quackking »

Perryg - I've done that in GuestA /etc/network/interfaces file as follows:

Code: Select all

# The loopback network interface
auto lo
iface lo inet loopback

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

iface eth0 inet static
   address 75.xxx.xxx.103
   netmask 255.255.255.0
    gateway 75.xxx.xxx.xxx
    post-up iptables-restore < /etc/iptables.up.rules
However, I have made no change to the Host /etc/network/interfaces file, and while I can ping Guest A on the public IP address *from the Host only,* I can't see it from the big internet.

How does the Host NIC get bound to the second public IP? does it happen automatically? The Host IP is presently set static to a single public IP (and I can see it on the big internet fine) - don't I need to set it to multiple IPs? That is my problem. Where and how do I do that on the host?

Again, thanks.
Martin
Volunteer
Posts: 2560
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by Martin »

When using bridged mode, the host NIC doesn't need to know the guest IP adresses. Very simplified you can think of bridged mode like a switch connecting your host NIC and all guest NICs to your network cable. Each guest will act like a dedicated physical machine.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Multi static IPs, 1 NIC, bridged to multi static guest IPs

Post by Sasquatch »

quacking, it's obvious you didn't even read my reply. What you are doing on the Host side is no longer needed, for almost a year (11 months)! Please read the User Manual, especially chapter 6 again.
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.
Post Reply