Debian – host only network xen 4.4

debianvirtual-machinesxen

I have one IP address (ipv4) and I am trying to install a domU (debian stable) on a dom0 which runs the latest xen 4.4.1 on debian testing.

I have created xenbr0 bridge and it is mapped to my eth0.

My domU can be started using xl create my.cfg and the installer (using the debian installer with initrd.gz and vmlinuz) starts. Then auto network config tries to obtain an ip via dhcp in my domU but the networking fails cause I do not have a dhcp server.

How can I manually set my domU to connect to the outside (wild internet) via the xenbr0 so that I can do a network install?

Thanks for any pointers.

update: .cfg

Nothing special there really

kernel = "/tmp/vmlinuz"
ramdisk = "/tmp/initrd.gz"
extra = "debian-installer/exit/always_halt=true -- console=hvc0"
vcpus = 4
memory = 2048
name = "debianvm"
vif = ['bridge=xenbr0']
disk = ['phy:/dev/vg0/debianvm,xvda,w']

Best Answer

You can setup NAT for your VM manually for example like this:

  1. Create another bridge: brctl addbr xenbr1

  2. Add it to your VM: bridge=xenbr1

  3. Bring the bridge UP with some network, for example ifconfig xenbr1 192.168.0.1/24 up
  4. Setup a DHCP server and configuration for your network

    subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.10 192.168.0.50; option routers 192.168.0.1; default-lease-time 600; max-lease-time 7200; }

    And bind DHCP to your bridge xenbr1. But you can skip this step. You'll just need to specify a static IP inside your installer.

  5. Add a SNAT rule, for example: iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j SNAT --to-source ...

  6. Allow forwarding net.ipv4.conf.all.forwarding = 1

After that you'll have a working network in your VM. Also you can specify vif = ['bridge=xenbr1,script=vif-nat'] in your VM config (more info here http://wiki.xenproject.org/wiki/Xen_Networking). It will automate some NAT settings. But in older versions of Xen it behaved strangely. I personally like to control anything so i prefer the method i described earlier.

Hope it helps.