Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Ubuntu Server and KVM, and am trying to figure out how to get networking to work so one guest can use multiple static IP addresses from one network adapter.

Right now I'm assuming a layout like this (all static):

eth0
 |- 192.168.1.100 - Server address A (eth0)
 |- 192.168.1.101 - Server address B (eth0:1)
 \- Virtual machine
     |- 192.168.1.150 - VM address C (eth0:2?)
     \- 192.168.1.151 - VM address D (eth0:3?)

I'm not quite sure how to go about setting this up in /etc/networking/interfaces or in virsh. I'm guessing a bridge needs to be involved, and that a network needs to be set up with libvirt, but I have no idea how to set either up.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

First, you need to create a bridge on your host server. This is what you need in the host configuration file for /etc/networking/interfaces.

auto br0
iface br0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.254
    bridge_ports    eth0
    bridge_stp      on
    bridge_maxwait  0

auto br0:0
iface br0:0 inet static
    address 192.168.1.101

and so forth (replace with your network config). The bridge_xxx parts are optional as certain defaults will be assumed otherwise.

Then for libvirt, you need to make sure that your VM guests are using the bridge as their network. The relevant part of the /etc/libvirt/qemu/vmname.xml config is:

<interface type='bridge'>
  <mac address='XX:XX:XX:xx:xx:xx'/>
  <source bridge='br0'/>
</interface>

Then, how you set up the two IPs inside the guest VM depends on the OS used inside the guest VM. If you are using a Debian based guest, then edit the networking files similar to the one on the host, but use eth0 instead of br0 and change the relevant IPs to 192.168.1.150/151 instead.

share|improve this answer
    
Thanks! I had tried the same bridging settings at one point, what I was missing was the settings in libvirt. –  Andrew Koester Dec 9 '10 at 19:18
    
Is there anything special I need to do with iptables to get this to work? –  Andrew Koester Dec 9 '10 at 19:32
    
Your firewall settings would need to be changed as well since the interface names are changed. The important thing to remember is to allow routeback on the bridge. –  sybreon Dec 10 '10 at 0:20
    
How can I restrict which IPs the client can use? –  gucki Dec 30 '11 at 18:52
    
@gucki - firewall settings on the host. –  sybreon Jan 4 '12 at 7:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.