KVM network bridge with public static IP for both host and guests

I have a Ubuntu 10.04 server with 2 public static addresses. There is a KVM guest (also Ubuntu) installed and running. What i want is to give the guest an IP of the host, so that both machines have public IPs.

When i create a bridge for the guest, add interfaces to the bridge then the host loses connectivity but the guest begins to be able to ping from outside.

What should i do to have connection for host and guest ?

This is network conf:

# ifconfig -a
br0       Link encap:Ethernet  Hardware Adresse ee:29:4b:xx:xx:xx  
          BROADCAST MULTICAST  MTU:1500  Metrik:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  Hardware Adresse 00:1a:4b:xx:xx:xx  
          inet Adresse:abc.def.xyz.100  Bcast:129.206.218.255  Maske:255.255.255.0
          inet6-Adresse: fe80::21a:4bff:fe46:eca4/64 Gültigkeitsbereich:Verbindung
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:16101 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13577 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000 
          RX bytes:6470077 (6.4 MB)  TX bytes:2058971 (2.0 MB)
          Interrupt:19 

eth0:0    Link encap:Ethernet  Hardware Adresse 00:1a:4b:46:ec:a4  
          inet Adresse:abc.def.xyz.101  Bcast:129.206.218.255  Maske:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          Interrupt:19

# route
Kernel-IP-Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
abc.def.xyz.0   *               255.255.255.0   U     0      0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 eth0
default         abc.def.xyz.1   0.0.0.0         UG    100    0        0 eth0

# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.000000000000       no              eth0
                                                        vnet0

There is no firewall enabled and DNS is configured properly.

What I want to achieve:

     |                         |            
+----+-------------------------+--------+
|    |          Host           |        |   
|    |                         |        |   
|    |            +------------+------+ |
|  eth0           |          eth0:0   | | 
|  x.x.x.100      |                   | |          
|                 |                   | |          
|                 |  br0     vnet0    | | 
|                 +------------+------+ |
|                              |        |   
|                              |        |   
|                 +------------+------+ |
|                 |            |      | |   
|                 |       eth0-+      | |
|                 |       x.x.x.101   | |
|                 |                   | |          
|                 |       Guest       | |
|                 +-------------------+ |
+---------------------------------------+

Solution 1:

I'm not sure if it's required, but this works for me:

  • eth0-on-the-host: no ip on host, added to bridge
  • vnet0: no ip on host, added to bridge
  • bridge: ip of the host
  • eth0-in-the-guest: ip of the guest

Note that most documentation suggests bringing the physical interface up with ip 0.0.0.0 after attaching it to the bridge.