Xen 4 – Combined Bridged And NAT Networking

Normally Xen is deployed with plenty of of public IPs,  so it can use bridged networking and each virtual machine can have it’s own public IP.  However in my case I was limited by only 1 public IP, but I wanted to run several VMs with services accessible from outside.  Solution was to modify XEN networking scripts.

Idea is to use an internal bridge with hidden IP subnet and to use NAT and port forwading so particular services on VMs can be reached from outside (on public IP, which is assigned to DOM0).This solution works for me successfully on Debian Squeeze.

First define two new scripts in /etc/xen/scripts/

/etc/xen/scripts/network-bridge-nat

/etc/xen/scripts/vif-bridge-nat

 

Then create new python script /etc/xen/scripts/portmap.py,  which will define port mapping on public interface:

netdev is public interface attached to DOM0
portmap is dictionary defining VMs port mapping, VMs should have static IPs – see comment in the code how to use it.  It should be defined for all your VMs, that should be accessible from outside.

Assure all scripts have execute rights.

Run in terminal:

Modify /etc/network/interfaces

And modify  /etc/xen/xend-config

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">