Archive for February, 2008

Multiple network cards and bridges in Xen

Wednesday, February 20th, 2008

Using multiple network cards associated to different bridges in Xen is quite easy. By default Xen uses ony one bridge.

Create custom network-script which works as a wrapper and calls network-bridge from it.

/etc/xen/scripts/multi-network-bridge:
(for Xen 3.1 and earlier)

#!/bin/sh
dir=$(dirname “$0″)
“$dir/network-bridge” “$@” vifnum=0 netdev=eth0 bridge=xenbr0
“$dir/network-bridge” “$@” vifnum=1 netdev=eth1 bridge=xenbr1

/etc/xen/scripts/multi-network-bridge:
(for Xen 3.2)

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

In Xen 3.2 the default bridge is changed from xenbr<n> to eth<n> and the eth<n> is renamed peth<n>

Add execute-permissions:

# chmod u+x /etc/xen/scripts/multi-network-bridge

Edit Xen’s config:
/etc/xen/xend-config.sxp:


#(network-script network-bridge)
(network-script multi-network-bridge)

DomU’s config:
/etc/xen/conf/foo.conf:
(for Xen3.1 and earlier)


vif = [ 'bridge=xenbr1'];

/etc/xen/conf/foo.conf:
(for Xen 3.2)


vif = [ 'bridge=eth1'];

Reboot Dom0 and you should see multiple bridges.

How to connect to bridged modem via wan-port

Wednesday, February 20th, 2008

My current configuration is:

{internal network 192.168.0.0/24} - [Linksys WRT54gl] - [A-Link RR44C] - {8/1 ADSL}

where A-Link is running in bridged mode (transparent) and thus doesn’t have a public IP. It can be managed via management IP (or LAN IP as it is identified in a config) which is by default 10.0.0.2.

The Linksys WRT54gl is acting as a firewall and a WLAN access point. It’s WAN-port is connected to A-Link’s LAN and it receives it’s public IP address directly from my ISP. Linksys’s LAN uses 192.168.0.0/24 subnet.

Linksys is running OpenWrt and X-Wrt.

To connect to the A-Link, previously I had to hook up a laptop to A-Link’s LAN-port and manually set the laptop’s IP-address to 10.0.0.10 (or anything else from 10.0.0.0/8 subnet) and then browse to 10.0.0.2, which is A-Link’s default management address.

To be able to connect to the A-Link from my internal network without hassling with a laptop and IP configurations, I had to add a IP alias to Linksys’s WAN-port (which is labeled by default as vlan1):
# ifconfig vlan1:0 10.0.0.10

Now Linksys WAN-port had two IP address’s. One that it received from isp (public) and 10.0.0.10. This command add a default route which works by default, so additional route configuration is not needed. However, if you wish to add a specific route, you can do it.

First remove the old route which routes all 10.0.0.0/8 traffic to wan-interface:
# route del -net 10.0.0.0 netmask 255.0.0.0

and then add a specific route, which routes only traffic to 10.0.0.2 via wan-interface:
# route add -host 10.0.0.2 dev vlan1:0