Changes

Manually adding a new bridge

5,764 bytes added, 09:03, 21 February 2014
/* Create a new bridging device */
= Overview =
The following page describes the steps to manually add a new Ethernet bridge (<code>vmbrX</code>) to an existing stoney cloud installation.In this example we presume you want to add the new Ethernet bridge <code>vmbr4</code>. == Before adding a new bridge ==<pre> +----------------+----------------+----------------+----------------+IP interfaces | 192.168.140.1X | 10.1.110.1X | 10.1.120.1X | 10.1.130.1X | +----------------+----------------+----------------+----------------+ +----------------+----------------+----------------+----------------+Bridging interfaces | vmbr0 | (vmbr1) | (vmbr2) | (vmbr3) | +----------------+----------------+----------------+----------------+ +----------------+----------------+----------------+----------------+VLAN interfaces | vlan140 | vlan110 | vlan120 | vlan130 | +----------------+----------------+----------------+----------------+ +-------------------------------------------------------------------+Bonding interfaces | bond0 (bonding.mode=802.3ad) | +-------------------------------------------------------------------+ +----------------+----------------+----------------+----------------+Physical interfaces | eth0 | eth1 | eth2 | ethN | +----------------+----------------+----------------+----------------+</pre> == After adding an additional bridge (vmbr4) ==<pre> +----------------+----------------+----------------+----------------+----------------+IP interfaces | 192.168.140.1X | 10.1.110.1X | 10.1.120.1X | 10.1.130.1X | 192.168.141.1X | +----------------+----------------+----------------+----------------+----------------+ +----------------+----------------+----------------+----------------+----------------+Bridging interfaces | vmbr0 | (vmbr1) | (vmbr2) | (vmbr3) | vmbr4 | +----------------+----------------+----------------+----------------+----------------+ +----------------+----------------+----------------+----------------+----------------+VLAN interfaces | vlan140 | vlan110 | vlan120 | vlan130 | vlan141 | +----------------+----------------+----------------+----------------+----------------+ +------------------------------------------------------------------------------------+Bonding interfaces | bond0 (bonding.mode=802.3ad) | +------------------------------------------------------------------------------------+ +----------------+----------------+----------------+---------------------------------+Physical interfaces | eth0 | eth1 | eth2 | ethN | +----------------+----------------+----------------+---------------------------------+</pre>
= Prerequisites =
To be able to add and configure a new bridge, you need to have the following informations present:
* The name of the bridge, such as <code>vmbr4</code> (<code>vmbr1</code>, <code>vmbr3</code> and <code>vmbr3</code> are reserved for existing networks)
* VLAN ID, such as <code>141</code>
* IP prefix, such as <code>192.0168.2141.0/24</code>* Default gateway address (if any), such as <code>192.0168.2141.1</code>* IP address for the DHCP server on the VM node, such as <code>192.0168.2141.13</code>* Broadcast address, such as <code>192.0168.2141.255</code>
Make sure, that you have configured the new VLAN on all involved switches and routers beforehand.
<pre>
71: vlan141@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT
link/ether XX38:XX60:XX77:XX9c:XX98:XX 40 brd ff:ff:ff:ff:ff:ff
</pre>
In order to bring the newly configured VLAN up after a system reboot, the network configuration needs to be extended. Edit <code>/etc/conf.d/net</code> and add the following entryentries:<source lang="bash"> $EDITOR /etc/conf.d/net</source>
<source lang="bash">
#-----------------------------------------------------------------------------
# VLAN (802.1q support)
### Add the new vlan to the bond device
vlans_bond0="130 120 110 140 141"
config_vlan140="null"
### Add your new vlan at the end of the VLAN section
# pub2 VLAN
vlan141_name="vlan141"
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 <code>vmbr0</code> bridge configuration. In the following example the bridge <code>vmbr4</code> is added on top of VLAN <code>141</code> with a prefix of <code>192.0168.2141.13/24</code>:<source lang="bash"> $EDITOR /etc/conf.d/net</source>
<source lang="bash">
# Bridging (802.1d) interfaces
bridge_vmbr0="vlanXXXvlan140"bridge_add_vlanXXXbridge_add_vlan140="vmbr0"config_vmbr0="XXX192.XXX168.XXX140.XXX13/XX 24 brd XXX192.XXX168.XXX140.XXX255" # 192.168.140.13 is the ip address of the vm-node.routes_vmbr0="default via XXX192.XXX168.XXX140.XXX1"
### Add your new bridge at the end of the bridge section
bridge_vmbr4="vlan141"
bridge_add_vlan141="vmbr4"
config_vmbr4="192.0168.2141.13/24 brd 192.0168.2141.255" # 192.168.141.13 is the ip address of the vm-node (only required on primary- and secondary master node for the dhcp server, on all others use: null)rc_net_vmbr4_provide="!net" # Otherwise stopping or restarting the bridge, will bring all net-services down.
</source>
 
To bring the bridge up, an init script is required. Simply symlink the <code>net.lo</code> script to the new bridge name's script, here <code>net.vmbr4</code> is assumed:
* Adding ports to vmbr4
* vlan141 ... [ ok ]
* 192.0168.2141.13/24 ... [ ok ]
</pre>
</source>
<pre>
7282: vmbr4: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether XX38:XX60:XX77:XX9c:XX98:XX 40 brd ff:ff:ff:ff:ff:ff inet 192.0168.2141.13/24 brd 192.0168.2141.255 scope global vmbr4
valid_lft forever preferred_lft forever
 bridge name bridge id STP enabled interfacesvmbr0 8000.3860779c9840 no kvm-0217_0 vlan140vmbr4 8000.3860779c9840 no kvm-0227_0 vlan141
</pre>
vlanId=141
bridgeName=vmbr4
nodeIp=192.0168.2141.13
prefixLength=24
broadcast=192.0168.2141.255
cat << EOF >> /etc/conf.d/net
bridge_add_vlan${vlanId}="${bridgeName}"
config_${bridgeName}="${nodeIp}/${prefixLength} brd ${broadcast}"
rc_net_${bridgeName}_provide="!net"
EOF
/etc/init.d/net.${bridgeName} start
ip addr show ${bridgeName} && brctl show
</source>
 
== Delete a bridging device ==
Tear the bridge down but check if it would also stop all network services:
<source lang="bash">
# Set your bridge name
bridgeName=<NAME OF YOUR BRIDGE> # e.g.: vmbr4
 
# Check if it excludes the net services
grep rc_net_${bridgeName}_provide /etc/conf.d/net
</source>
If grep produces output you might consider running the initscript with the ''-D'' options (otherwise network services, like sshd, might get stopped).
 
Otherwise just stop the bridge and remove the initscript:
<source lang="bash">
/etc/init.d/net.${bridgeName} stop
 
rc-update del net.${bridgeName} default
 
rm /etc/init.d/net.${bridgeName}
</source>
 
Remove the bridge from the network configuration:
$EDITOR /etc/conf.d/net
 
<source lang="bash">
# [...]
 
### Remove the options for the bridge you want to delete
#bridge_vmbr4="vlan141"
#bridge_add_vlan141="vmbr4"
#config_vmbr4="192.168.141.13/24 brd 192.168.141.255" # 192.168.141.13 is the ip address of the vm-node.
#rc_net_vmbr4_provide="!net" # Otherwise stopping or restarting the bridge, will bring all net-services down.
 
# [...]
</source>
 
== Remove a VLAN on a bonding interface ==
Delete the VLAN from the interface bond0:
<source lang="bash">
# Set your vlan id
vlanId=<VLAN ID> # e.g. 141
 
# Shut the vlan down
ip link set vlan${vlanId} down
 
# Remove it from the interface bond0
ip link delete vlan${vlanId} type vlan
</source>
 
Edit <code>/etc/conf.d/net</code> and remove your VLAN:
$EDITOR /etc/conf.d/net
 
<source lang="bash">
# [...]
 
### Remove your vlan options
# pub2 VLAN
# vlan141_name="vlan141"
# config_vlan141="null"
 
# [...]
</source>
* [http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=4&chap=3#doc_chap7 Gentoo Handbook - Bridging (802.1d support)]
* [http://wiki.gentoo.org/wiki/Network_bridge Gentoo Wiki - Network Bridge]
 
[[Category:Workarounds]]
16
edits