<?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>Tom&#039;s Thoughts &#187; Linux</title>
	<atom:link href="http://compton.nu/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://compton.nu</link>
	<description></description>
	<lastBuildDate>Tue, 20 Jul 2010 16:44:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Per-Packet Load Balancing with Linux</title>
		<link>http://compton.nu/2009/12/per-packet-load-balancing-with-linux/</link>
		<comments>http://compton.nu/2009/12/per-packet-load-balancing-with-linux/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 12:08:33 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://compton.nu/?p=144</guid>
		<description><![CDATA[The ISP I use at home and at work, Andrews and Arnold, support bonding of multiple lines with per-packet load balancing. Incoming traffic is handled by them using custom hardware and software &#8211; the control panel lets me select which lines should be used for each block of IP addresses and they then handle balancing [...]]]></description>
			<content:encoded><![CDATA[<p>The ISP I use at home and at work, <a href="http://aaisp.net.uk/">Andrews and Arnold</a>, support bonding of multiple lines with per-packet load balancing. Incoming traffic is handled by them using custom hardware and software &#8211; the control panel lets me select which lines should be used for each block of IP addresses and they then handle balancing the traffic over those lines on a per-packet basis.</p>
<p>At work we have four ADSL lines and to handle the load outgoing balancing we use a set of four ordinary DSL routers connected by ethernet to a four port D-Link ethernet card in a linux server which then does per-packet load balancing for outgoing traffic using the teql traffic scheduler. This post describes how we configure the load balancing.</p>
<p><span id="more-144"></span>The first step is to give each of the routers (we use Zyxel P660 routers) two different LAN addresses &#8211; one is in the 172.16 private address range and is unique to each router and used to address specific routers for management and configuration purposes; and the other is a common address from the block allocated to use by our ISP and is shared by all the routers.</p>
<p>The ability to configure multiple addresses for the LAN side interface is a requirement for this technique to work, and not all routers may support it&#8230;</p>
<p>Once that is done, we start the linux configuration (this is a RedHat/Fedora style system) by defining the bonded interface, teql0, by creating a teql.conf file in /etc/modprobe.d which defines an appropriate alias:</p>
<pre>alias teql0 sch-teql</pre>
<p>We then have to define the configuration for each interface in the normal way, with ifcfg files in /etc/sysconfig/network-scripts, starting with an ifcfg-ethN file for each of the bonded ethernet interfaces that looks something like:</p>
<pre>DEVICE=eth{2,3,4,5}
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.8.{1,5,9,13}
NETMASK=255.255.255.252
HWADDR=...</pre>
<p>This places each ethernet interface on a local /30 network that is simply used for management purposes to allow each router to be connected to for configuration. An ifcfg-teql0 file is then created to define the bonded interface:</p>
<pre>DEVICE=teql0
BOOTPROTO=static
IPADDR=...
NETMASK=...
ONBOOT=yes</pre>
<p>The network details here are those for the IP range allocated by the ISP to us as this is the public interface where traffic sent to and from the ISP will be handled.</p>
<p>Next we have to make sure that reverse path filtering for the physical ethernet interfaces we are using is set to loose mode as they will be receiving packets that look like they should arrive on the traffic equalizer interface. To do this we edit /etc/sysctl.conf and add a line for each interface that looks like this:</p>
<pre>net.ipv4.conf.eth{2,3,4,5}.rp_filter = 2</pre>
<p>In order to bond the individual ethernet interfaces into the traffic equalizer we first create an ifup-pre-local script in /sbin which makes sure the teql0 interface is created before the ethernet interfaces are configured:</p>
<pre>#!/bin/sh

case "$1" in
 ifcfg-eth2|ifcfg-eth3|ifcfg-eth4|ifcfg-eth5) modprobe teql0;;
esac</pre>
<p>We then create an ifup-local script which adds the ethernet interfaces to the traffic equalizer:</p>
<pre>#!/bin/sh

case "$1" in
 eth2|eth3|eth4|eth5) tc qdisc add dev $1 root teql0;;
esac</pre>
<p>For good measure, an ifdown-local script removes the interfaces again:</p>
<pre>#!/bin/sh

case "$1" in
 eth2|eth3|eth4|eth5) tc qdisc del dev $1 root;;
esac</pre>
<p>A default route that uses the new bonded interface can be added in the normal by adding a line to /etc/sysconfig/network:</p>
<pre>GATEWAY=...</pre>
<p>The gateway address here is the common IP address allocated to each router.</p>
<p>For firewalling and packet tracing purposes, you should note that outgoing packets will be seen going into teql0 rather than the individual interfaces, but incoming packets will appear from each of the four ethernet interfaces, depending on which line they arrive from the ISP over.</p>
<p>That&#8217;s really about all there is to it &#8211; we do also have a small daemon process that monitors the lines and removes them from the traffic equalizer if they go down and adds them back when they come up again.</p>
<p><strong>UPDATE: The traffic equalizer is completely broken in kernels 2.6.31 through 2.6.34&#8230;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://compton.nu/2009/12/per-packet-load-balancing-with-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Low Power Firewall</title>
		<link>http://compton.nu/2009/10/building-a-low-power-firewall/</link>
		<comments>http://compton.nu/2009/10/building-a-low-power-firewall/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 20:24:21 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.compton.nu/?p=65</guid>
		<description><![CDATA[For a number of years now I have used my old desktop computers to act as firewalls for my home network &#8211; when my desktop is upgraded the old firewall is freecycled and the old desktop becomes the new firewall.
A powerful desktop computer in a large tower case has a number of disadvantages however, both [...]]]></description>
			<content:encoded><![CDATA[<p>For a number of years now I have used my old desktop computers to act as firewalls for my home network &#8211; when my desktop is upgraded the old firewall is <a href="http://www.freecycle.org/">freecycled</a> and the old desktop becomes the new firewall.</p>
<p>A powerful desktop computer in a large tower case has a number of disadvantages however, both in terms of it&#8217;s physical size and the amount of power it needs to run on a 24/7 basis. So I have been meaning for some time to replace my firewall with a small, purpose built, low power system.</p>
<p>In the last few weeks I have finally got around to going ahead with this task so, after some hours perusing the hardware porn at <a href="http://www.linitx.com/">LinITX</a> I ordered an Intel D945GSEJT Atom based Mini-ITX motherboard and the exceedingly tiny Mini-Box M350 case. Here we see the result, with a 2Gb SODIMM and a 4Gb SATA flash module added.</p>
<div id="attachment_69" class="wp-caption aligncenter" style="width: 330px"><a href="http://compton.nu/wp-content/uploads/2009/10/firewall1.jpg"><img class="size-full wp-image-69   " title="Firewall with basics installed" src="http://compton.nu/wp-content/uploads/2009/10/firewall1.jpg" alt="Firewall with motherboard, memory, SATA flash module and WIFI aerials installed" width="320" height="312" /></a><p class="wp-caption-text">Firewall with motherboard, memory, SATA flash module and WIFI aerials installed</p></div>
<p>Also visible here are a pair of dual frequency (2.4/5.0 GHz) aerials for WiFi as the firewall will also be replacing my existing wireless access point. An extra hole had to be drilled in the back plate for the second aerial, which necessitated a trip round the corner to the hardware store as sod&#8217;s law dictated that a 6.5mm hole was needed when the largest HSS bit in my collection was 6mm in size&#8230;</p>
<p><span id="more-65"></span></p>
<p>Part of my LinITX order was an Intel 512AN Mini-PCIe wireless card &#8211; this was carefully chosen based on the fact that Intel WiFi cards are well supported in the linux kernel with modern, mac80211 based drivers. Unfortunately as soon as I started investigating how to configure it as an access point it quickly became clear that the drivers for the Intel WiFi cards do not, in fact, support AP mode. The main authors of the drivers appear to be Intel themselves, and there seems to be <a href="http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=1585">little enthusiasm for supporting AP mode</a>.</p>
<p>So that card went back (distance selling regulations to the rescue!) and in it&#8217;s place I sourced an Atheros card instead, which was easier said than done &#8211; Mini-PCIe wireless cards are surprisingly hard things to find, perhaps because they mainly sell to laptop manufacturers on a wholesale basis. I also had to wait a full week for <a href="http://www.royalmail.com/">Royal Mail</a> to manage to deliver it (a first class recorded package) and that was before they went on strike!</p>
<p>While I was waiting for the replacement wireless card to arrive I was able to install the PCI riser (which had arrived a few days late having been missed when my order was packed) and a gigabit network card harvested from my old firewall which would provide the second network port needed in the firewall.</p>
<p style="text-align: left;">
<div id="attachment_70" class="wp-caption aligncenter" style="width: 330px"><a href="http://compton.nu/wp-content/uploads/2009/10/firewall2.jpg"><img class="size-full wp-image-70  " title="Firewall with PCI network card installed" src="http://compton.nu/wp-content/uploads/2009/10/firewall2.jpg" alt="Firewall with PCI riser and second Gb network card installed" width="320" height="217" /></a><p class="wp-caption-text">Firewall with PCI riser and gigabit network card installed</p></div>
<p style="text-align: left;">Finally, the replacement wireless card arrived and was installed in the Mini-PCIe slot (under the PCI card) and the aerials connected. All that was then needed was to knock up a configuration file for <a href="http://w1.fi/hostapd/">hostapd</a> and it was up and running as an AP and the radio on my old Netgear access point could be turned off.</p>
<p style="text-align: left;">The only outstanding issue is that while my laptop (running linux) is quite happy to talk to the new AP my Windows Mobile 5 PDA seems to object to it for some reason that is still not entirely clear &#8211; it appears to successfully attach to the wireless network and sends DHCP requests but seems to be unable to receive (or perhaps to decrypt) the replies.</p>
<p style="text-align: left;">
<div id="attachment_71" class="wp-caption aligncenter" style="width: 330px"><a href="http://compton.nu/wp-content/uploads/2009/10/firewall3.jpg"><img class="size-full wp-image-71  " title="The completed firewall" src="http://compton.nu/wp-content/uploads/2009/10/firewall3.jpg" alt="The completed firewall, all ready to be installed in it's new home" width="320" height="224" /></a><p class="wp-caption-text">The completed firewall, all ready to be installed</p></div>
<p>So, after all that, my new firewall/access point is now installed in my network and, within a few hours of offering my old firewall on freecycle about a dozen different people had offered to take it (despite it lacking any operating system) and it now has a new home.</p>
]]></content:encoded>
			<wfw:commentRss>http://compton.nu/2009/10/building-a-low-power-firewall/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
