Wednesday, February 9, 2011

How to configure XEN to use NAT or Bridge networks.

For configurig Xen Virtualisation Server to use bridge or NAT networks:


Edit File : /etc/xen/xend-config.sxp


For NAT:

(network-script 'network-nat netdev=eth0')
(vif-script     vif-nat)

For Bridge:


by default netdev is always eth0.
if you want to change it to eth1 device then,
eg:
(network-script 'network-bridge netdev=eth1')
(vif-script vif-bridge)

You can also bind Guest OS exclusively to one Bridge
Edit  /xen_home/xen_vm1/vm.cfg 

vif = ['ip=10.228.141.202','bridge=xenbr0', 'mac=00:16:3E:0B:87:2B']

ip= IP of guest OS
Bridge = xenbr0 is mapped to eth0 which is assigned ip of network 10 series
mac=mac address of Guest OS.



#brctl show 
will list the Bridge Name and device its bridged to, eg below :
# brctl show
bridge name     bridge id               STP enabled     interfaces
xenbr0          8000.001517cd0ad2       no              vif39.2
                                                        vif39.1
                                                        vif39.0
                                                        vif38.0
                                                        eth0




You will find the network-bridge script in below location :

# pwd
/etc/xen/scripts


# ls
block                    network-bridges  vtpm-common.sh
block-common.sh          network-nat      vtpm-delete
block-enbd               network-route    vtpm-hotplug-common.sh
block-nbd                vif-bridge       vtpm-impl
external-device-migrate  vif-common.sh    vtpm-migration.sh
image_domU.sh            vif-nat          xen-hotplug-cleanup
locking.sh               vif-route        xen-hotplug-common.sh
logging.sh               vscsi            xen-network-common.sh
network-bridge           vtpm             xen-script-common.sh


reload xend (/etc/init.d/xend reload)

If bridge is up default name will be like xenbr0

Take a look at file /etc/xen/xend-config.sxp to change default bridge name or for
 more directives and options.


*Make sure the gateway you have given in Guest OS is same as Host Gateway or else wont be reachable from outside.



Also theres a good tutorial on Xen networking which you can  check here



No comments:

Post a Comment