Manually adding a new bridge

Revision as of 12:09, 12 February 2014 by Chrigu (Talk | contribs)


Overview

The following page describes the steps to manually add a new Ethernet bridge (vmbrX) to an existing stoney cloud installation.

Prerequisites

To be able to add and configure a new bridge, you need to have the following informations present:

  • VLAN ID, such as 141
  • IP prefix, such as 192.0.2.0/24
  • Default gateway address (if any), such as 192.0.2.1
  • IP address for the DHCP server on the VM node, such as 192.0.2.13
  • Broadcast address, such as 192.0.2.255

Make sure, that you have configured the new VLAN on all involved switches and routers beforehand.

Configuration

Add the new VLAN on top of the bonding interface

Login to the first VM node and manually add the new VLAN to the existing bonding interface (bond0). In the following example VLAN 141 is added:

ip link add link bond0 name vlan141 type vlan id 141
ip link set vlan141 up
ip link show vlan141
71: vlan141@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT 
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff

In order to bring the newly configured VLAN up after a system reboot, the network configuration needs to be extended. Edit /etc/conf.d/net and add the following entry:

$EDITOR /etc/conf.d/net
# [...]
 
#-----------------------------------------------------------------------------
# VLAN (802.1q support)
 
vlans_bond0="130 120 110 140 141"
 
# pub VLAN
vlan140_name="vlan140"
config_vlan140="null"
 
### Add your new vlan at the end of the VLAN section
# pub2 VLAN
vlan141_name="vlan141"
config_vlan141="null"
 
# [...]

Create a new bridging device

As the new VLAN interface is now up, an additional bridge can be added.

Again the network configuration needs to be edited. Append the configuration of the new bridge, below the existing vmbr0 bridge configuration. In the following example the bridge vmbr4 is added on top of VLAN 141 with a prefix of 192.0.2.13/24:

$EDITOR /etc/conf.d/net
# [...]
 
#-----------------------------------------------------------------------------
# Bridging (802.1d) interfaces
 
bridge_vmbr0="vlanXXX"
bridge_add_vlanXXX="vmbr0"
config_vmbr0="XXX.XXX.XXX.XXX/XX brd XXX.XXX.XXX.XXX"
routes_vmbr0="default via XXX.XXX.XXX.XXX"
 
### Add your new bridge at the end of the bridge section
bridge_vmbr4="vlan141"
bridge_add_vlan141="vmbr4"
config_vmbr4="192.0.2.13/24 brd 192.0.2.255"
rc_net_vmbr4_provide="!net" # Otherwise stopping or restarting the bridge will bring all net-services.


To bring the bridge up, an init script is required. Simply symlink the net.lo script to the new bridge name's script, here net.vmbr4 is assumed:

ln -s /etc/init.d/net.lo /etc/init.d/net.vmbr4
rc-update add net.vmbr4 default
/etc/init.d/net.vmbr4 start
 * Caching service dependencies ...                                       [ ok ]
 * Bringing up interface vmbr4
 *   Creating bridge vmbr4 ...
 *   Adding ports to vmbr4
 *     vlan141 ...                                                        [ ok ]
 *   192.0.2.13/24 ...                                                    [ ok ]

Check if everything looks fine:

ip addr show vmbr4 && brctl show
72: vmbr4: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.13/24 brd 192.0.2.255 scope global vmbr4
       valid_lft forever preferred_lft forever

bridge name	bridge id		STP enabled	interfaces
vmbr4		8000.3860779c9840	no		vlan141


Or if you would like to copy&paste:

vlanId=141
bridgeName=vmbr4
nodeIp=192.0.2.13
prefixLength=24
broadcast=192.0.2.255
 
cat << EOF >> /etc/conf.d/net
 
bridge_${bridgeName}="vlan${vlanId}"
bridge_add_vlan${vlanId}="${bridgeName}"
config_${bridgeName}="${nodeIp}/${prefixLength} brd ${broadcast}"
EOF
 
ln -s /etc/init.d/net.lo /etc/init.d/net.${bridgeName}
rc-update add net.${bridgeName} default
/etc/init.d/net.${bridgeName} start
ip addr show ${bridgeName} && brctl show

Links

Last modified on 12 February 2014, at 12:09