PDA

View Full Version : Xen networking


ziogra
11th March 2009, 13:22
Hi,

I have a question for you, maybe can you help me.

I have a xen box (debian lenny) with 2 NICs. I'd like to use

eth0 (bridging) for VMs on the LAN
eth1 ( ? ) for a VM with a static public ip (I have only 1 public IP)

The only way I get it working is configuring the real eth1 and the VM's eth0 with the same public IP.
Is there an IP conflict danger? How can I configure xen in a better way to get the same result? (eg: eth1 route or nat ?)

Here's my config:

mynet script to create 2 separate bridges:
(I call it from xend-config.sxp)

#!/bin/sh
dir=$(dirname "$0")
"$dir/network-bridge" "$@" vifnum=0 netdev=eth0 bridge=eth0
"$dir/network-bridge" "$@" vifnum=1 netdev=eth1 bridge=eth1


/etc/network/interfaces:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth0 eth1
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
allow-hotplug eth1

iface eth0 inet static
address 192.168.34.252
netmask 255.255.255.0
gateway 192.168.34.250
broadcast 192.168.34.255

# PUBLIC STATIC IP ADDRESS
iface eth1 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx
broadcast xxx.xxx.xxx.xxx


Thank you in advance!
Stefano

falko
12th March 2009, 20:53
Have you tried to specify the Xen bridge in each guest's configuration file (in the vif line)?

vif = [ 'bridge=eth0,...' ]
or
vif = [ 'bridge=eth1,...' ]

ziogra
13th March 2009, 09:55
yes, my question was:

how can I set a bridge without assigning to it a public IP?

In the meanwhile I've found an additional IP address. That solved my problem: one IP to the bridge, one to the VM, but I'd like to know anyway how to set a "nohost" bridge.

Thank you!
Stefano

matey
16th March 2009, 16:30
You did the the same way as we have it set up
we set IP in the Xen guest machine's /etc/network/interfaces file;

like
auto eth1
iface eth1 inet static
address 10.0.0.10 (or any IP address you want or one assigned by ISP)
netmask 255.255.255.0 (or whatever your subnet is)


and of course before that you set your NICs in the " vif= " statement in xen.conf file as Falko said.
I am no expert but I think that is where you set up your gateway as well.
when a virtual NIC points to the real IP address it acts as a gateway, I think?!
Just make sure the 2nd NIC is actually connected (to a hub /switch or router)

mactor
18th March 2009, 12:21
yes, my question was:

how can I set a bridge without assigning to it a public IP?

Thank you!
Stefano

To set up a bridge in Xen with no IP address you can have this in /etc/network/interfaces

auto eth1
iface eth1 inet manual
pre-up ifconfig $IFACE up
post-down ifconfig $IFACE down

This brings the bridge up with no ip address, and you don't need to have it connected to a switch...etc.

Replace eth1 with the interface/bridge you need and reboot.