# setting up gentoo xen dom0 with multiple bridges [solved]

## newtonian

Hi-

I'm trying to setup a xen server with 2 bridges.  Anyone have a conf.d/net that creates 2 bridges from 2 physical nics?

Here's my current config.  It works to setup xenbr0 great.  The 2nd bridge doesn't start up.  Any sample configs or links to gentoo specific xen mulitple bridge docs or advice on how to get the script below to work would be appreciated:

```
#dns_domain_eth0="mydomain.com"

#

config_eth0=(

        "210.48.123.123 netmask 255.255.255.192 brd 210.48.123.255"

)

config_eth1=(

        "192.168.0.1 netmask 255.255.255.0 brd 192.168.0.255"

)

dns_servers_eth0="210.48.123.3 210.48.123.2"

#

routes_eth0=(

  "default via 210.48.123.1"             # IPv4 default route

)

bridge_xenbr0="eth0"

brctl_xenbr0=(

 "setfd 0"

 "sethello 0"

 "stp off"

)

#

config_xenbr0=(

        "210.48.123.123 netmask 255.255.255.192"

)

routes_xenbr0=( "default via 210.48.123.1" )

bridge_xenbr1="eth1"

brctl_xenbr1=(

 "setfd 0"

 "sethello 0"

 "stp off"

)

#

config_xenbr1=(

        "192.168.0.1 netmask 255.255.255.255"

)

routes_xenbr1=( "default via 192.168.0.1" )

```

```
shark scripts # /etc/xen/scripts/network-bridge status

============================================================

13: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue

    link/ether 00:15:13:54:32:74 brd ff:ff:ff:ff:ff:ff

    inet 210.48.255.51/26 brd 210.48.255.255 scope global eth0

13: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue

    link/ether 00:15:13:54:35:74 brd ff:ff:ff:ff:ff:ff

    inet 210.48.255.51/26 brd 210.48.255.255 scope global eth0

bridge name     bridge id               STP enabled     interfaces

eth0            8000.001517543174       no              peth0

210.48.123.0/26 dev eth0  proto kernel  scope link  src 210.48.123.123

127.0.0.0/8 dev lo  scope link

default via 210.48.123.1 dev eth0

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

210.48.255.0    0.0.0.0         255.255.255.192 U     0      0        0 eth0

127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

0.0.0.0         210.48.123.1    0.0.0.0         UG    0      0        0 eth0

============================================================
```

```
shark scripts # ifconfig

eth0      Link encap:Ethernet  HWaddr 00:15:17:11:11:74

          inet addr:210.48.123.123  Bcast:210.48.123.255  Mask:255.255.255.192

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:25406 errors:0 dropped:0 overruns:0 frame:0

          TX packets:13173 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:19944443 (19.0 Mb)  TX bytes:2150992 (2.0 Mb)

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:56 errors:0 dropped:0 overruns:0 frame:0

          TX packets:56 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:4340 (4.2 Kb)  TX bytes:4340 (4.2 Kb)

peth0     Link encap:Ethernet  HWaddr 00:15:17:11:11:74

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:25412 errors:0 dropped:0 overruns:0 frame:0

          TX packets:13175 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:20402417 (19.4 Mb)  TX bytes:2207442 (2.1 Mb)

          Base address:0x2020 Memory:b8820000-b8840000

```

Last edited by newtonian on Fri Aug 15, 2008 9:34 am; edited 2 times in total

----------

## newtonian

found this: 

Not exactly sure how it works.  Any pointers appreciated.

https://bugs.gentoo.org/show_bug.cgi?id=151764#c62

----------

## newtonian

OK, I got it working!  Here's what I did.

1. added the 2nd interface to /etc/init.d/

```

cd /etc/init.d

ln -s net.lo net.eth1

ln -s net.lo net.xenbr1

```

2. created this file:

```

vim /etc/xen/scripts/network-bridge-wrapper

chmod 755 /etc/xen/scripts/network-bridge-wrapper

```

with this content:

```
#!/bin/sh

/etc/xen/scripts/network-bridge $1 netdev=eth0

/etc/xen/scripts/network-bridge $1 netdev=eth1
```

3. added the following to /etc/conf.d/net :

```
config_eth0=( "dhcp" )

config_eth1=(

       "222.48.255.51 netmask 255.255.255.192 brd 222.48.255.255"

)

bridge_xenbr0="eth0"

brctl_xenbr0=( "setfd 0" "sethello 0" "stp off" )

config_xenbr0=( dhcp )

routes_xenbr0=( "default via 192.168.0.1" )

bridge_xenbr1="eth1"

brctl_xenbr1=( "setfd 0" "sethello 0" "stp off" )

routes_xenbr1=( "default via 222.48.255.1" )

config_xenbr1=(

        "222.48.255.51 netmask 255.255.255.192"

)

```

4. replaced network-bridge with network-bridge-wrapper in /etc/xen/xend-config.sxp.

```
vim /etc/xen/xend-config.sxp
```

Here is the new line:

```

(network-script network-bridge-wrapper)

```

You can confirm your setup by running ifconfig after reboot:

```
/sbin/ifconfig
```

```
eth0      Link encap:Ethernet  HWaddr 00:15:17:54:31:74

          inet addr:192.168.0.185  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:308316 errors:0 dropped:0 overruns:0 frame:0

          TX packets:3460370 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:19602574 (18.6 Mb)  TX bytes:5235735778 (4993.1 Mb)

eth1      Link encap:Ethernet  HWaddr 00:15:17:54:31:75

          inet addr:222.48.255.51  Bcast:222.48.255.255  Mask:255.255.255.192

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:5 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:1004 (1004.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:56 errors:0 dropped:0 overruns:0 frame:0

          TX packets:56 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:4340 (4.2 Kb)  TX bytes:4340 (4.2 Kb)

peth0     Link encap:Ethernet  HWaddr 00:15:17:54:31:74

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:308173 errors:0 dropped:0 overruns:0 frame:0

          TX packets:3458703 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:25141922 (23.9 Mb)  TX bytes:5247034711 (5003.9 Mb)

          Base address:0x3020 Memory:b9420000-b9440000

peth1     Link encap:Ethernet  HWaddr 00:15:17:54:31:75

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:11 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1478 (1.4 Kb)  TX bytes:128 (128.0 b)

          Base address:0x3000 Memory:b9400000-b9420000

```

 5. domU config

```
cat /mnt/data/xen/configs/gentoo

kernel = "/mnt/data/xen/kernel/vmlinuz-2.6.21-xenU"

memory = 2048

name   = "gentoo"

disk   = ['file:/mnt/data/xen/disks/ext3root.img,sda1,w']

root   = "/dev/sda1"

vif = [ "mac=00:11:50:00:00:51, bridge=xenbr0" ]

vcpus  = 4

```

 6. in your domU, setup /etc/conf.d/net as you would normally.  Keep in mind that this domU is only connected to xenbr0 (192.168.0.0) network as per the vif attribute set in the config file above, you should be able to add a second mac and bridge to that vif statement in the config above but I haven't tested it.

This worked for me.  Please let me know if something or many things are incorrect here.  I couldn't find any other howtos or forum topics gentoo specific on this topic.  Hope this helps others.  

Cheers,

----------

## newtonian

New HowTo for Xen 4 on Gentoo

Make xen0 kernel with netloop and netbk as modules, added the following to 

/etc/modules.autoload.d/kernel-2.6.

```
vim /etc/modules.autoload.d/kernel-2.6
```

```
netloop nloopbacks=1

netbk
```

make it so that gentoo doesn't try to use the standard network scripts:

```
vim /etc/conf.d/rc
```

```
RC_PLUG_SERVICES="!net.*"
```

```
rm /etc/init.d/net.eth0; rm /etc/init.d/net.eth1
```

```
rc-update net.eth0 del; rc-update net.eth1 del
```

```
cd /etc/init.d/;ln -s net.lo net.xenbr0;ln -s net.lo net.xenbr1
```

Add xenbr0 and xenbr1 to default run level

```
rc-update add net.xenbr0 default

rc-update add net.xenbr1 default
```

update /etc/conf.d/net

```
vim /etc/conf.d/net
```

```
# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_xenbr0=( "192.168.1.1 netmask 255.255.255.0" )

bridge_xenbr0="eth0"

routes_xenbr0=( "default via 192.168.1.1" ) 

config_xenbr1=( "210.48.2.50 netmask 255.255.255.192" )

bridge_xenbr1="eth1"

routes_xenbr1=( "default via 210.48.2.1" ) 

dns_servers_xenbr1=( "203.141.128.135 203.141.128.133" )

dns_domain_xenbr1="mydomain.com"

# end of /etc/conf.d/net

```

notice nothing refers to config_eth0 or config_eth1, all of these references have been replaced by config_xenbr0 and config_xenbr1

comment out the network-bridge script by commenting out the call to the script in /etc/xen/xend-config.sxp

```
vim /etc/xen/xend-config.sxp 

#(network-script network-bridge)  make sure network-bridge script is not called and comment out this line
```

domU example:

```
vif = [ 'mac=00:11:50:00:00:97,bridge=xenbr1' ]

# I needed the next line for gentoo vm's, other vm's may require something else ie. extra="xencons=ttyS"

extra=”xencons=tty console=tty1″
```

Based on these articles:

https://forums.gentoo.org/viewtopic-t-689293-highlight-xen+bridge.html

http://foxpa.ws/2010/06/06/gentoo-xen-4-migration/

----------

