2012년 2월 11일 토요일

Xen: how to configure bridge network manually

Suddenly, the network was not enable to work on server (centos 5.6 + xen)
The problem was that ping to external sites like google.com didn't work.  
It seemed that it was something wrong with xen's bridge network, because I was able to ping when the bridge was disabled.


$ /etc/xen/scripts/network-bridge stop


After this, I was able to ping to external site, but it wasn't the answer. I installed xen again, it didn't, too. my choice was to configure bridge for the xen manually.


Configuring bridge network
In my case, I used static ip for the eth0 network and I newly created bridge network named "br0". That static ip was to use on bridge network.


Copy config file of eth0 to create the bridge network named "br0".
$ cd etc/sysconfig/network-scripts
$ cp ./ifcfg-eth0 ifcfg-br0


Configure ifcfg-br0
$ vi ./ifcfg-br0
DEVICE=br0
TYPE=Bridge            => The first letter "B" must be upper-case.
ONBOOT=yes
BOOTPROTO=static
IPADDR=xxx.xxx.xxx.xxx
GATEWAY=xxx.xxx.xxx.xxx
NETMASK=255.255.255.0
NM_CONTROLLED=no


Configure ifcfg-eth0 to link to the bridge and remove ip section.
$ vi ./ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
NM_CONTROLLED=no


Restart network
$ service network restart



Configuring xen
When xen starts, xen is trying to set own bridge network. Internally, xen executes network-bridge script, which: 
  1. reates a new bridge named xenbr0
  2. "real" ethernet interface eth0 is brought down
  3. the IP and MAC addresses of eth0 are copied to virtual network interface veth0
  4. real interface eth0 is renamed peth0
  5. virtual interface veth0 is renamed eth0
  6. peth0 and vif0.0 are attached to bridge xenbr0. Please notice that in xen 3.3, the default bridge name is the same than the interface it is attached to. Eg: bridge name eth0, eth1 or ethX.VlanID
  7. the bridge, peth0, eth0 and vif0.0 are brought up
This was different from my intent. so I had to disable this by editing xend-config.sxp file.
$ vi /etc/xen/xend-config.sxp

#(network-script network-bridge)   => It have to be commented.
(network-script /bin/true)              => It have to be added.



Restart xen and check bridges.
$ service xend restart
$ brctl show
bridge name     bridge id               STP enabled     interfaces
virbr0           8000.000000000000      yes
br0              8000.000e0cb30550       yes             eth0

I did ping to external site again, I finally worked. virbr0 is the bridge which is created automatically when libvirts starts. 


Reference sites:
1. http://wiki.libvirt.org/page/Networking
2. http://wiki.xensource.com/xenwiki/XenNetworking
3. http://wiki.kartbuilding.net/index.php/Xen_Networking

댓글 없음:

댓글 쓰기