<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>twam.info &#187; Switch</title>
	<atom:link href="http://www.twam.info/tag/switch/feed" rel="self" type="application/rss+xml" />
	<link>http://www.twam.info</link>
	<description>My computer, physics, electronics &#38; photography blog</description>
	<lastBuildDate>Wed, 25 Jan 2012 20:49:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ethernet bonding with Linux and 802.3ad</title>
		<link>http://www.twam.info/linux/ethernet-bonding-with-linux-and-8023ad</link>
		<comments>http://www.twam.info/linux/ethernet-bonding-with-linux-and-8023ad#comments</comments>
		<pubDate>Wed, 06 May 2009 16:04:30 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network/Web]]></category>
		<category><![CDATA[Switch]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=402</guid>
		<description><![CDATA[Nowadays, most desktop mainboards provide more than one gigabit ethernet port. Connecting them both to the same switch causes most Linux distros by default to get a individual IP on each device and route traffic only on the primary device (based on device metric) or round-robin. A single connection always starts at one IP and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.twam.info/wp-content/uploads/2009/05/2nic_switch.png"><img class="alignright size-full wp-image-412" title="2 NIC + Switch" src="http://www.twam.info/wp-content/uploads/2009/05/2nic_switch.png" alt="2 NIC + Switch" width="117" height="87" /></a>Nowadays, most desktop mainboards provide more than one gigabit ethernet port. Connecting them both to the same switch causes most Linux distros by default to get a individual IP on each device and route traffic only on the primary device (based on device metric) or round-robin. A single connection always starts at one IP and so all traffic goes through one device, limiting maximum bandwidth to 1 GBit.</p>
<p>Here comes bonding (sometimes called (port) trunking or link aggregation) to play. It connects two ore more ethernet ports to one virtual port with only one MAC and so mostly one IP address. Wheres earlier only two hosts (with the same OS running) or two switches (from the same vendor) could be connected, nowadays there&#8217;s a standard protocol which makes it easy: <a href="http://en.wikipedia.org/wiki/Link_Aggregation_Control_Protocol#Link_Aggregation_Control_Protocol">LACP</a> which is part of <a href="http://en.wikipedia.org/wiki/802.3ad">IEEE 802.3ad</a>. <span id="more-402"></span>Linux supports difference bonding mechanisms including 802.3ad. To enable bonding at all there are some kernel settings needed:</p>
<pre>Device Drivers  ---&gt;
[*] Network device support  ---&gt;
&lt;*&gt;   Bonding driver support</pre>
<p>After compiling and rebooting, we need a userspace tool for configuring the virtual interface. It&#8217;s called ifenslave and provided with the Linux kernel. You can either compile it by hand</p>
<pre>/usr/src/linux/Documentation/networking
gcc -Wall -O -I/usr/src/linux/include ifenslave.c -o ifenslave
cp ifenslave /sbin/ifenslave</pre>
<p>or install it by emerge if you run <a href="http://www.gentoo.org">Gentoo Linux</a>:</p>
<pre>emerge -va ifenslave</pre>
<p>Now we can configure the bonding device, called bond0. Firstofall we need to set the 802.3ad mode and the MII link monitoring frequency by</p>
<pre>echo "802.3ad" &gt; /sys/class/net/bond0/bonding/mode
echo 100 &gt;/sys/class/net/bond0/bonding/miimon</pre>
<p>Now we can up the device and add some ethernet ports:</p>
<pre>ifconfig bond0 up
ifenslave bond0 eth0
ifenslave bond0 eth1</pre>
<p>Now bond0 is ready to be used. Run a dhcp client or set an IP by</p>
<pre>ifconfig bond0 192.168.1.2 netmask 255.255.255.0</pre>
<p>These steps are needed on each reboot. If you&#8217;re running gentoo, you can use baselayout for this. Add</p>
<pre>config_eth0=( "none" )
config_eth1=( "none" )
preup() {
	# Adjusting the bonding mode / MII monitor
	# Possible modes are : 0, 1, 2, 3, 4, 5, 6,
	#     OR
	#   balance-rr, active-backup, balance-xor, broadcast,
	#   802.3ad, balance-tlb, balance-alb
	# MII monitor time interval typically: 100 milliseconds
	if [[ ${IFACE} == "bond0" ]] ; then
		BOND_MODE="802.3ad"
		BOND_MIIMON="100"
		echo ${BOND_MODE} &gt;/sys/class/net/bond0/bonding/mode
		echo ${BOND_MIIMON}  &gt;/sys/class/net/bond0/bonding/miimon
		einfo "Bonding mode is set to ${BOND_MODE} on ${IFACE}"
		einfo "MII monitor interval is set to ${BOND_MIIMON} ms on ${IFACE}"
	else
		einfo "Doing nothing on ${IFACE}"
	fi
	return 0
}
slaves_bond0="eth0 eth1"
config_bond0=( "dhcp" )</pre>
<p>to your /etc/conf.d/net. I found this nice preup part in the <a href="http://www.gentoo-wiki.info/HOWTO_Setup_Bonded_ethernet_adapters">Gentoo Wiki Archive</a>.</p>
<p>Now you have to configure the other side of the link. You can either use a Linux box and configure it the same way or a 802.3ad-capable switch. I used an <a href="http://www.hp.com/rnd/products/switches/HP_ProCurve_Switch_1800_Series/overview.htm">HP Procurve 1800-24G</a> switch. You have to enable <a href="http://en.wikipedia.org/wiki/Link_Aggregation_Control_Protocol#Link_Aggregation_Control_Protocol">LACP</a> on the ports you&#8217;re connected:</p>
<p style="text-align: left;">
<div id="attachment_403" class="wp-caption aligncenter" style="width: 220px"><a href="http://www.twam.info/wp-content/uploads/2009/05/hp1800_lacp.png"><img class="size-medium wp-image-403" title="HP Procurve 1800-24G LACP Configuration" src="http://www.twam.info/wp-content/uploads/2009/05/hp1800_lacp-210x143.png" alt="HP Procurve 1800-24G LACP Configuration" width="210" height="143" /></a><p class="wp-caption-text">HP Procurve 1800-24G LACP Configuration</p></div>
<p>Now everything should work and you can enjoy a 2 GBits (or more) link. Further details can be found in the <a href="http://www.linuxfoundation.org/en/Net:Bonding">kernel documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/linux/ethernet-bonding-with-linux-and-8023ad/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

