Xen and Multiple Networks


Last Friday I asked a question about how to set up a network in Xen with a machine attached between a public and private network, like you might use in a firewall or load balancing situation. I want to be able to mimic real world networking situation in Xen for experimentation and modeling purposes.

There were numerous replies and I'm grateful for all the help. In the end, Steve Fulling (he's not as pointy haired as you though) came up with a pretty simple solution.

To use virt-install to create a bridged, public machine, you'd do something like this:

virt-install --paravirt --vcpus=1 --name $1 --ram 500 \\\\
             --file /var/lib/xen/images/${1}.img
             --network=bridge:eth0 \\\\
             --file-size 10 --nographics \\\\
             --location http://192.168.1.150/fedora8-i386

To use virt-install to create a private machine, you'd do something like this:

virt-install --paravirt --vcpus=1 --name $1 --ram 500 \\\\
             --file /var/lib/xen/images/${1}.img
             --network=network:default \\\\
             --file-size 10 --nographics \\\\
             --location http://192.168.1.150/fedora8-i386

The trick to getting a machine on both is to issue two --network commands:

virt-install --paravirt --vcpus=1 --name $1 --ram 500 \\\\
             --file /var/lib/xen/images/${1}.img  \\\\
             --network=bridge:eth0 --network=network:default \\\\
             --file-size 10 --nographics \\\\
             --location http://192.168.1.150/fedora8-i386

There are other, more complex scenarios. For example, you might want to create multiple VLANs, etc. I found these resources helpful: