<?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>Aptivate &#124; A Blog for ICT4D &#187; Infrastructure</title>
	<atom:link href="http://blog.aptivate.org/category/infrastructure/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.aptivate.org</link>
	<description>International I.T. Development</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:09:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.6</generator>
		<item>
		<title>Content indexing in Django using Apache Tika</title>
		<link>http://blog.aptivate.org/2012/02/01/content-indexing-in-django-using-apache-tika/</link>
		<comments>http://blog.aptivate.org/2012/02/01/content-indexing-in-django-using-apache-tika/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 13:12:44 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Engineer's Log]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=992</guid>
		<description><![CDATA[For the Documents module of our new open-source Generic Intranet, we need to be able to extract the text content and metadata from various kinds of documents: PDF files Microsoft Office DOC, XLS and PPT files and the new XML equivalents, DOCX, XLSX and PPTX. I found various tools online to help extract this text, [...]]]></description>
			<content:encoded><![CDATA[<p>For the Documents module of our new open-source <a href="https://github.com/aptivate/intranet">Generic Intranet</a>, we need to be able to extract the text content and metadata from various kinds of documents:</p>
<ul>
<li>PDF files</li>
<li>Microsoft Office DOC, XLS and PPT files</li>
<li>and the new XML equivalents, DOCX, XLSX and PPTX.</li>
</ul>
<p>I found various tools online to help extract this text, largely thanks to Stack Overflow <a href="http://superuser.com/questions/165978/command-line-tool-in-linux-to-extract-text-from-word-excel-powerpoint-or-co">here</a> and <a href="http://stackoverflow.com/questions/888784/extract-text-from-a-powerpoint-ppt-or-pptx-file">here</a>. This ended up with a hodgepodge of tools:</p>
<ul>
<li><a href="http://www.unixuser.org/~euske/python/pdfminer/">PDF Miner</a> for PDF files</li>
<li><a href="http://github.com/mikemaccana/python-docx/tarball/master">python-docx</a> for DOCX files</li>
<li><a href="http://silvercoders.com/en/products/doctotext/">DocToText</a> for PPTX, XLSX and PPT files</li>
<li><a href="http://www.winfield.demon.nl/">antiword</a> for DOC files</li>
</ul>
<p>There were a number of problems with this hodgepodge:</p>
<ul>
<li>I was <strong>unable to find</strong> any Python or command-line solution for <strong>old Excel (XLS) files</strong><strong>;</strong></li>
<li>These solutions did not extract metadata, only document text;</li>
<li>The choice of which tool to use depends on the MIME type returned by the <a href="http://www.darwinsys.com/file/">file(1)</a> command, which varies depending on the OS (Debian/Ubuntu or CentOS) and which version of the library is installed</li>
</ul>
<p><a href="http://stackoverflow.com/questions/2239459/python-based-document-metadata-parser">Another Stack Overflow post</a> recommended Apache Tika for metadata extraction. It appears to support all the document formats that we need, and to have auto-detection of the document format, which solves all the MIME type problems as well. However, it introduces a new problem: it&#8217;s written in Java, which is hard to access from Python.</p>
<p>Luckily I found some <a href="http://redmine.djity.net/projects/pythontika/wiki">instructions</a> for building a Python wrapper around Tika, using some tools that I&#8217;d never heard of, and this seemed like a good approach. Unfortunately the installation process is very non-standard, which would not fit in with our fabric-based automated deployment process, and would make it harder for users to install the Intranet themselves.</p>
<p>The instructions are somewhat outdated at the time of writing, as they refer to Tika version 0.7, while 1.0 has been released. I was unable to register for an account to update that page, so I wrote to the author with the details that I discovered, and will also document here that the following command works for me:</p>
<pre>python ../jcc/jcc/__main__.py \
        --include /usr/share/java/org.eclipse.osgi.jar \
        --jar tika-parsers-1.0.jar \
        --jar tika-core-1.0.jar \
        java.io.File java.io.FileInputStream \
        java.io.StringBufferInputStream \
        --package org.xml.sax \
        --include tika-app-1.0.jar \
        --python tika --version 1.0 --reserved asm</pre>
<p>I was able to go further than this, and package Tika in a way that makes it easy to install with Pip, and thus integrate with our deployment process.</p>
<p>The wrapper is written using JCC, which works by generating and compiling C++ code that links to the Java classes, and then a Python wrapper around that C++. This means that it needs to be recompiled for each platform, so I couldn&#8217;t just distribute a binary blob with the Intranet (I had the same problem with DocToText above).</p>
<p>The version of setuptools on our servers doesn&#8217;t support JCC&#8217;s <a href="http://lucene.apache.org/pylucene/jcc/documentation/install.html#shared">shared library mode</a>. JCC dies with an error if it&#8217;s not explicitly disabled or the patch applies. I couldn&#8217;t do either of these as part of our standard deployment process. So I <a href="https://github.com/aptivate/jcc">patched JCC</a> to disabled shared mode, since we don&#8217;t need it anyway. I also added some patches to allow various <code>setup.py</code> commands used by <code>pip</code> to be forwarded through JCC to the <code>setup</code> function call.</p>
<p>This seems to be enough to allow you to install JCC like this:</p>
<pre>pip install git+git://github.com/aptivate/jcc.git</pre>
<p>I also wrote a setup.py file that handles pip&#8217;s command line invokations and passes the necessary options to JCC, and JCC&#8217;s invocation of the setup function. This seems to be enough to install the package using pip:</p>
<pre>pip install git+git://github.com/aptivate/python-tika.git</pre>
<p>and you can use the last parameter as a package specification in pip_packages.txt, or whatever you pass to pip -r.</p>
<p>You can find the pip-installable Tika package, complete with <a href="http://repo1.maven.org/maven2/org/apache/tika/">Tika 1.0 JAR files</a>, in our <a href="https://github.com/aptivate/python-tika">python-tika</a> repository on Github. This will save you the work of downloading and compiling Tika and all of its dependencies. I have started a <a href="http://mail-archives.apache.org/mod_mbox/lucene-pylucene-dev/201202.mbox/%3Calpine.DEB.2.02.1202011310060.5732%40lap-x201%3E">discussion</a> with the JCC developers about merging these changes into the upstream project.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2012/02/01/content-indexing-in-django-using-apache-tika/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ICTs for Rural Development Seminar</title>
		<link>http://blog.aptivate.org/2010/10/27/icts-for-rural-development-seminar/</link>
		<comments>http://blog.aptivate.org/2010/10/27/icts-for-rural-development-seminar/#comments</comments>
		<pubDate>Wed, 27 Oct 2010 13:29:44 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Appropriate Technology]]></category>
		<category><![CDATA[Design and Usability]]></category>
		<category><![CDATA[Government]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Mobiles]]></category>
		<category><![CDATA[PDAs]]></category>
		<category><![CDATA[data collection]]></category>
		<category><![CDATA[participation]]></category>
		<category><![CDATA[agriculture]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[rural]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=725</guid>
		<description><![CDATA[Just attended a very interesting seminar on The Rural Information Economy and ICTs, hosted by the UN Food and Agriculture Organisation (FAO), a major actor in this area, at their headquarters in Rome. This is an area in which Aptivate is also very interested, and one in which I&#8217;ve done some research and been following [...]]]></description>
			<content:encoded><![CDATA[<p>Just attended a very interesting seminar on <a href="http://www.e-agriculture.org/660.html">The Rural Information Economy and ICTs</a>, hosted by the <a href="http://www.fao.org">UN Food and Agriculture Organisation</a> (FAO), a major actor in this area, at their headquarters in Rome.</p>
<p>This is an area in which Aptivate is also very interested, and one in which I&#8217;ve done some research and been following developments. I still managed to learn quite a bit from three very interesting presentations:</p>
<h3><a href="http://www.slideshare.net/eagriculture/unctad-information-economy-report-2010">Information Economy Report 2010 (UNCTAD)</a></h3>
<p>The informational dimension of poverty, i.e. where information can help to alleviate or reduce poverty:</p>
<ul>
<li>Market price information</li>
<li>Income-earning opportunities (e.g. jobs)</li>
<li>Weather information and warnings</li>
<li>Correct use of pesticides and fertilisers</li>
<li>Health information and education</li>
<li>Disaster risk reduction</li>
</ul>
<p>Communication up and down the supply chain, and with peers and advisors, also helps.</p>
<p>There is an increasing trend to direct involvement of the beneficiaries in the production of ICTs:</p>
<ul>
<li>As ICT workers</li>
<li>Manufacturing of ICTs (as an alternative occupation to subsistence farming)</li>
<li>Providing IT and ICT-enabled services (answering questions, finding information, running telecentres)</li>
</ul>
<p>Mobile phone penetration has exceeded all other ICTs in growth in developing countries. On average in the least developed countries, it has increased from 2% to 26% of the population (1000% growth) from 2000 to 2009. Possibly the fastest-spreading technology ever in the history of the world.</p>
<p>Growth is uneven. There are still some LDCs where less than 10% of the population have a mobile phone. In Ethiopia for example, only 5% have a phone. This was largely attributed to lack of liberalisation of telecomms markets.</p>
<p>Half of rural population in LDCs have no access to a mobile phone signal, which will limit the further growth of mobile usage. Many Universal Service Funds are sitting unused. In some cases this is because they are mandated only to be used on the fixed line network, which is nearly obsolete.</p>
<p>Mobile micro-insurance has become a big topic. For example:</p>
<ul>
<li><a href="http://kilimosalama.wordpress.com/about/">Kilimo Salama</a> in Kenya</li>
<li>Burkina Faso, Mali (index-based crop insurance)</li>
<li>Alliance Afrique</li>
</ul>
<p>Kilimo Salama recently <a href="http://kilimosalama.wordpress.com/2010/10/07/first-m-pesa-payouts/">made their first payouts</a> to farmers because weather conditions exceeded their thresholds. The payouts are automatic and don&#8217;t have to be claimed by the farmers. The largest was about $30.</p>
<p>Even those who don&#8217;t have access to ICTs themselves can benefit from more transparent markets when enough participants use ICTs.</p>
<p><a href="http://www.unctad.org/Templates/webflyer.asp?docid=13912&#038;intItemID=2068&#038;lang=1">Download the full report</a> (PDF, 171 Pages, 1240Kb).</p>
<h3><a href="http://www.slideshare.net/eagriculture/ifad-michael-hampruraldevelopmentandict27102010">Enabling role of ICTs to transform smallholder farmers to entrepreneurs (IFAD)</a></h3>
<p>IFAD offers grants and loans to governments for argicultural development programmes. They are starting to offer grants (but not loans) to the private sector as well.</p>
<p>Grameen and BRAC had limited success with mobile banking (so far), because most of their customers are groups, not individuals, and mobile phones tend to be personal devices.</p>
<p>IFAD and WFP are running a joint project called the <a href="http://www.ifad.org/ruralfinance/wrmf/">Weather Risk Management Facility (WRMF)</a>, a micro-insurance project. Half of the insurance premiums are paid by the farmers, and half by the sellers of inputs (seeds, fertilizer, pesticides) as they benefit from farmers being willing to buy more of their products due to reduced risk of crop failure.</p>
<h3><a href="http://www.slideshare.net/eagriculture/fao-ic-tinagricultureoct20103">ICTs enhancing plant production at the field level (FAO)</a></h3>
<p><a href="http://www.fao.org/ag/locusts/en/activ/DLIS/eLocust/index.html">e-Locust2</a> uses vehicles with GPS, laptops and HF radio modems to send real-time information on locust swarms to governments, which can help to warn and prepare neighbouring villages and allow the targeted use of pesticides to control the pests. Time is critical to achieve this.</p>
<p>Digital Pens are being used to capture information entered on forms. The pen recognises what is being written, and where on the form, and captures the data for later upload. This makes it possible to have electronic filing with minimal training, minimal unreliable ICTs, an inherent fallback to paper-based methods, and hard copies of the forms that can be given to farmers or stored in local offices.</p>
<p>There are problems getting pest monitoring officials to enter high quality data when there is no incentive (reward) for accurate data, e.g. in one-way monitoring systems. If governments used this data to target their interventions, villagers would have a much more obvious incentive to ensure that the data was entered accurately and on time.</p>
<h3>Thanks</h3>
<p>Thanks to FAO for hosting this excellent seminar, and to the World Food Programme for allowing me time off to attend it.</p>
<p>Several of us expressed an interest in continuing the discussion online, we have been heard, and Michael Riggs, lead facilitator of the e-Agriculture Community, is working on enabling this to happen. There will also be a follow-on discussion at the <a href="http://www.ictd2010.org/">ICTD 2010 Conference</a> in London.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/10/27/icts-for-rural-development-seminar/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple Cisco VPN How-To</title>
		<link>http://blog.aptivate.org/2010/08/03/simple-cisco-vpn-how-to/</link>
		<comments>http://blog.aptivate.org/2010/08/03/simple-cisco-vpn-how-to/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 21:24:42 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Engineer's Log]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=605</guid>
		<description><![CDATA[One of our fellow Humanitarian Centre organisations, Engineers Without Borders UK (EWB), asked for our help in setting up a virtual private network (VPN), so that their remote workers can access their file server. This is something that ought to be really simple. It&#8217;s probably the most common use case of VPNs, Windows has a [...]]]></description>
			<content:encoded><![CDATA[<p>One of our fellow <a href="http://www.humcentre.org">Humanitarian Centre</a> organisations, <a href="http://www.ewb-uk.org">Engineers Without Borders UK</a> (EWB), asked for our help in setting up a virtual private network (VPN), so that their remote workers can access their file server.</p>
<p>This is something that ought to be really simple. It&#8217;s probably the most common use case of VPNs, Windows has a built-in VPN client, and Cisco routers can be used as VPN servers. EWB want it to be simple, because they have non-technical remote workers. It turned out to be much harder and take much longer than I expected.</p>
<h3>Information Overload</h3>
<p>One of the biggest problems was the lack of useful information, and the profusion of useless. The information fell mainly into four categories:</p>
<ul>
<li>Cisco marketing materials touting the benefits of VPNs and their expensive Concentrator and WebVPN products;</li>
<li>Cisco knowledge base articles describing the setup of complex VPN scenarios;</li>
<li>Cisco command references with little or no details on what each command actually does, or how to use them together;</li>
<li>Cisco exam study sites with inaccurate, out-of-date or cookie-cutter command sequences, with even less explanation of what the commands actually do.</li>
</ul>
<p>Because I couldn&#8217;t find what I was looking for, and had to work it out the hard way, I&#8217;ve written it up in the hope that it will help others.</p>
<p>I would recommend any organisations that simply want to share files to seriously consider a file-sharing service like <a href="http://dropbox.com">DropBox</a> or raw <a href="http://s3.amazonaws.com">Amazon S3</a> instead of a local file server and VPN. In many cases the low upload bandwidth of ADSL connections, combined with internal office use of the connection. will make a VPN impractically slow, especially compared to Amazon&#8217;s unlimited upload and download bandwidth. But EWB already had the file server and they just wanted to access it remotely, not to change how they work.</p>
<p>Our scenario is simple: an internal office network with private IP addresses, a Cisco 1800 router providing ADSL connectivity for the office, and remote field workers running Windows desktops.</p>
<h3>Getting the Client</h3>
<p>For simplicity, we and EWB had hoped to use the built-in VPN client on Windows, which would remove the need to download and install software on the remote workers&#8217; machines. But unfortunately the Cisco 1800 does not support this. Windows uses L2TP over IPSEC for modern, secure VPNs, as a replacement for the old insecure PPTP protocol. But Cisco has crippled the L2TP support in this router, and it only supports raw IPSEC. Only their more expensive routers support serving L2TP over IPSEC, allowing simple direct connections from Windows.</p>
<p>Raw IPSEC is the only remaining option on this router, but it&#8217;s difficult to configure due to its complexity, and the number of choices that need to be made. The standard requires both sides to have the same settings configured, but provides no way to do this automatically. Manual configuration would make life very hard for the remote workers. To solve this problem, Cisco has a non-standard protocol for auto-configuration of the clients:</p>
<blockquote><p>
Establishing a VPN connection between two routers can be complicated, and it typically requires tedious coordination between network administrators to configure the two routers&#8217; VPN parameters.</p>
<p>The Cisco Easy VPN Client feature eliminates much of this tedious work by implementing Cisco&#8217;s Unity Client protocol, which allows most VPN parameters to be defined at [the] IPSec server. </p>
<p><a href="http://www.cisco.com/en/US/products/hw/routers/ps221/prod_configuration_guide09186a008007cfa7.html#wp101952">Cisco Easy VPN Client for the Cisco 1700 Series Routers</a>
</p></blockquote>
<p>So we needed to find a replacement client that was easy to use and could talk to the Cisco. Preferably a free one.</p>
<p>Then we discovered that although Cisco&#8217;s own VPN client is technically free, you can&#8217;t actually download it without a support contract, which neither we nor EWB have.</p>
<p>In the end we found that if you go to Cisco&#8217;s <a href="http://tools.cisco.com/support/downloads/pub/ImageList.x?relVer=5.0.07.0290&#038;mdfid=281940730&#038;sftType=VPN+Client+Software&#038;optPlat=Windows&#038;nodecount=2&#038;edesignator=null&#038;modelName=Cisco+VPN+Client+v5.x&#038;treeMdfId=268438162&#038;treeName=Security&#038;modifmdfid=&#038;imname=&#038;hybrid=&#038;imst=&#038;lr=Y">VPN client software page</a>, find the filename of the latest version of the client, and Google it, you&#8217;ll find that <a href="http://www.google.co.uk/search?q=vpnclient-win-msi-5.0.07.0290-k9.exe&#038;ie=utf-8&#038;oe=utf-8&#038;aq=t&#038;rls=com.ubuntu:en-GB:unofficial&#038;client=firefox-a">several people</a> have had enough of this nonsense and posted the client online, so it can be downloaded.</p>
<p>Of course it&#8217;s important to be aware of the potential for viruses in copies that you download from random sites on the Internet, as well as fake download sites that lead you around in circles of free registrations, credit card details and pop-up porn adverts. <a href="http://samsten.net/work/cvpnc/">This site</a> worked fine for me, but it may have been taken down by Cisco&#8217;s attack dogs by the time you read this.</p>
<h3>Security with Obscurity</h3>
<p>We decided to choose a configuration that trades some security for ease of use. So instead of authenticating with certificates, we used pre-shared keys. The VPN server has its own login system anyway, which provides an additional layer of security once the remote user is connected to the VPN.</p>
<h3>Names and Addresses</h3>
<p>Connecting clients need to be allocated an IP address to use over the VPN. We could have used public IPs, or private IPs in the same subnet (with <a href="http://www.ciscocatalyst.info/en/US/docs/ios/ipaddr/command/reference/iad_arp.html#wp1013235">proxy ARP</a>), but we chose to use private IPs in a different subnet. This makes the routing easier, as clients and local network servers will know that they have to route the traffic via the router anyway, and it allows EWB to implement stricter network access policies for VPN clients, if they wish. </p>
<p>We needed to create a local pool (not a DHCP pool) to draw these addresses from:</p>
<pre>
ip local pool vpnpool 192.168.2.100 192.168.2.200
</pre>
<h3>Keys to the Kingdom</h3>
<p>We created an ISAKMP (IKE) policy to specify the authentication method and the level of encryption to be used for negotiation of IPSEC Security Associations (SAs). We chose to make this the first, highest priority policy, and to use AES-256 encryption (strong and fast), Group 2 (1024-bit) Diffie-Hellman key exchange, and pre-shared keys for client authentication as noted above:</p>
<pre>
crypto isakmp policy 1
 encr aes 256
 authentication pre-share
 group 2
</pre>
<p>Then we specified the pre-shared key itself. This is the only thing that stops random clients on the Internet from connecting to your local network, so it&#8217;s even more important than a strong wireless network key. Of course this is not the real key:</p>
<pre>
crypto isakmp key ThisKeyMustBeKeptSecret address 0.0.0.0 0.0.0.0
</pre>
<p> We specify that any IP address can use it by using the wildcard address, <code>0.0.0.0 0.0.0.0</code>.</p>
<h3>At the End of the Tunnel</h3>
<p>It seems to be common in corporate environments that, when a user is connected to a VPN, all of their Internet traffic is routed through the VPN. It certainly makes it easier for the network administrators, as they don&#8217;t have to define specific routes for the tunnel, but it wastes their bandwidth and makes Internet access much slower for the remote workers, so we decided not to do this.</p>
<p>Just routing a single subnet through a tunnel is called a <em>split tunnel</em>. I couldn&#8217;t find simple documentation on setting it up, so I used the <a href="http://www.cisco.com/en/US/docs/ios/sec_secure_connectivity/configuration/guide/sec_easy_vpn_rem.html#wp1060585">Cisco Easy VPN Remote example</a>, extracting just the bits we needed to route only the 192.168.1.0/24 subnet through the tunnel.</p>
<p>First we have to create an access control list (ACL) that defines, on the local (source address) side, what traffic clients should route into the tunnel:</p>
<pre>
ip access-list extended ewb_office_split_tunnel
 remark Defines which local (office) networks a remote VPN client will route to
 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
</pre>
<p>I&#8217;m not sure if the second half of the ACL is actually necessary. It doesn&#8217;t appear to make any difference if I specify <code>any</code> instead of <code>192.168.2.0 0.0.0.255</code>.</p>
<h3>Client Configuration</h3>
<p>We use Cisco&#8217;s EzVPN (Unity) protocol, as described earlier, to configure connecting clients automatically. To do this, we have to tell the server what configuration should be sent to clients when they connect:</p>
<pre>
crypto isakmp client configuration group EWB
 key ThisKeyMustBeKeptSecret
 dns 192.168.1.1
 wins 192.168.1.2
 pool vpnpool
 acl ewb_office_split_tunnel
 netmask 255.255.255.0
</pre>
<p>A little explanation about what these options do:</p>
<dl>
<dt>crypto isakmp client configuration group [name]</dt>
<dd>The <em>name</em> must match the <strong>group name</strong> that the client uses when it connects. This is how the server decides which configuration to send to the client.</dd>
<dt>key</dt>
<dd>For some reason the client needs to be told what key to use, even though it&#8217;s already been entered by the user, and the client knows it because it wouldn&#8217;t be able to get this far in the negotiation without it!
</dd>
<dt>dns</dt>
<dd>Tells the client which DNS server to use, for resolving local (private) hostnames, or resolving inside the split horizon. You can specify a second DNS server after the primary one. You probably only need this if you&#8217;re running a Windows domain, in which case it should point to the domain controller, or if you have split horizon DNS.</dd>
<dt>wins</dt>
<dd>Tells the client which WINS server to use, for resolving local SMB server names. Again, you probably only need this if you&#8217;re running a Windows domain, in which case it should also point to the domain controller.</dd>
<dt>pool</dt>
<dd>Tells the server which local pool (not DHCP pool) to assign the client&#8217;s address from. You can specify any name here, even a pool that doesn&#8217;t exist, but clients won&#8217;t be able to connect unless the pool name is a valid local pool.</dd>
<dt>acl</dt>
<dd>This ACL, which we defined earlier, is used to tell the clients which subnets are reachable through the connection (split tunnel mode). If no <strong>acl</strong> statement is used, the tunnel is not split, and a default route is set through the VPN tunnel instead.</dd>
<dt>netmask</dt>
<dd>Defines the network mask that the client will apply to its client interface, in combination with the IP address assigned from the pool.</dd>
</dl>
<h3>Profiling</h3>
<p>Next, we create an ISAKMP profile on the server which tells the server to assign IP addresses automatically, and which <a href="http://www.cisco.com/en/US/docs/ios/12_2/dial/configuration/guide/dafvrtmp.html#wp1000958">virtual template</a> to use when creating the virtual-access interfaces for the server side of the tunnel. We haven&#8217;t defined the virtual template yet, but we will in a second.</p>
<pre>
crypto isakmp profile ewb_isakmp_profile
   match identity group EWB
   isakmp authorization list sdm_vpn_group_ml_4
   client configuration address respond
   virtual-template 1
</pre>
<p>When a client connects using the group name <code>EWB</code>, it will check for network authorization using the AAA list name <code>sdm_vpn_group_ml_4</code> (or <code>default</code> if that list doesn&#8217;t exist), respond to IP address requests from the client (using the pool defined in the client configuration above), and create a local virtual-access interface based on virtual template number 1.</p>
<p>You should use the same group name that you used for the <strong>client configuration</strong> above, instead of EWB, unless you&#8217;re EWB of course.</p>
<h3>Strong Encryption</h3>
<p>Now we define the level of encryption used for data communications with hosts on the internal network, as opposed to securing the negotiation process. We start by defining a <em>transform set</em> which uses 256-bit AES encryption, the SHA hash algorithm and LZS compression for data packets:</p>
<pre>
crypto ipsec transform-set ewb_encryption esp-aes 256 esp-sha-hmac comp-lzs
</pre>
<p>Then we create an IPsec profile that links these settings to the ISAKMP profile that we defined above:</p>
<pre>
crypto ipsec profile ewb_ipsec_profile
 set transform-set ewb_encryption
 set isakmp-profile ewb_isakmp_profile
</pre>
<h3>Virtual Template</h3>
<p>Now we define the template for the virtual interfaces, that we referenced above in the ISAKMP policy:</p>
<pre>
interface Virtual-Template1 type tunnel
 ip unnumbered Vlan1
 zone-member security in-zone
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile ewb_ipsec_profile
</pre>
<p>We use <code>ip unnumbered Vlan1</code> to set the IP address of the virtual-access interfaces to the address of the router on the local LAN (in this case it&#8217;s a VLAN bridge), which allows you to ping the router using its internal IP address (192.168.1.1 in our case) when you&#8217;re connected to the VPN, which is a useful connectivity test.</p>
<p>We place the virtual interfaces into the <code>in-zone</code> (internal zone) which means that they have full access to the local network, which is not very secure, but simplifies things. We also specify that this interface accepts only traffic encrypted with IPsec and bound to the profile that we created earlier. I&#8217;m not sure why it needs to be bound in both directions, as the IPsec profile is connected to the ISAKMP profile which is connected to this virtual interface already.</p>
<h3>Client Setup</h3>
<p>That should be it for the server-side setup. To configure a client, install the VPN software you downloaded earlier, start it, create a new IPsec configuration, and enter the following details:</p>
<dl>
<dt>Server</dt>
<dd>The public IP address of the VPN server</dd>
<dt>Group Name</dt>
<dd>The same group name that you used on the server earlier</dd>
<dt>Pre-Shared Key</dt>
<dd>The same key that you entered on the server earlier</dd>
</dl>
<p>Now click on the <strong>Connect</strong> button, and after a few seconds the window should minimize to the system tray, and you should be connected to the VPN. You can check this by pinging the internal IP address of the router (e.g. 192.168.1.1) and if that works, the IP addresses of whatever internal servers you want to connect to.</p>
<p>If it doesn&#8217;t work, use the Log menu to enable logging, try to connect again, and check the results on the Logging tab. You can also try enabling IPsec debugging on the router, in run mode (not configuration mode):</p>
<pre>
debug crypto engine packet
debug crypto ipsec error
debug crypto isakmp error
debug crypto verbose
terminal monitor
</pre>
<p>When the configuration works, write it to the router&#8217;s non-volatile memory to ensure that you don&#8217;t lose it when you next reboot the router:</p>
<pre>
write
</pre>
<p>And that&#8217;s it!</p>
<h3>References</h3>
<p>Here are some random unsorted links to pages that I found useful while figuring out how to do this:</p>
<ul>
<li><a href="http://www.ciskoblog.com/2006/12/configuring-a-c.html">Configuring a Cisco Router to Accept VPN Connections</a> (even simpler example, without split tunnels)</li>
<li><a href="http://www.cisco.com/en/US/docs/ios/sec_secure_connectivity/configuration/guide/sec_key_exch_ipsec.html">Configuring Internet Key Exchange for IPsec VPNs</a> (good general overview of how Cisco&#8217;s IPsec works)</li>
<li><a href="http://www.cisco.com/en/US/docs/ios/sec_secure_connectivity/configuration/guide/sec_easy_vpn_rem.html#wp1060585">Cisco Easy VPN Remote</a> configuration guide</li>
<li><a href="http://samsten.net/work/cvpnc/">Cisco VPN client downloads</a></li>
<li><a href="http://www.ciscocatalyst.info/en/US/docs/ios/ipaddr/command/reference/iad_arp.html#wp1013235">Cisco ARP Commands</a></li>
<li><a href="http://www.cisco.com/en/US/products/ps6017/products_command_reference_chapter09186a00808ab59a.html#wp1016030">Cisco ISAKMP command reference</a></li>
<li><a href="http://www.cisco.com/en/US/docs/routers/access/cisco_router_and_security_device_manager/24/software/user/guide/ZPF.html#wp1020392">Configuring Zone Policy Firewalls</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/08/03/simple-cisco-vpn-how-to/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>System Imaging for Free using G4L</title>
		<link>http://blog.aptivate.org/2010/07/22/free-system-imaging-using-g4l/</link>
		<comments>http://blog.aptivate.org/2010/07/22/free-system-imaging-using-g4l/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 13:05:34 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Engineer's Log]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[AfNOG]]></category>
		<category><![CDATA[ghost]]></category>
		<category><![CDATA[imaging]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=594</guid>
		<description><![CDATA[This is a copy of the notes that I wrote at AfNOG 2010 as a guide to using system imaging at future workshops. Unfortunately that wiki is not accessible without signing up for an account, so I&#8217;m posting the information here too. How to Install Computer Labs If you ever need to set up a [...]]]></description>
			<content:encoded><![CDATA[<p>This is a copy of the <a href="http://nsrc.org/workshops/2010/afnog/wiki/SystemImaging">notes</a> that I wrote at AfNOG 2010 as a guide to using system imaging at future workshops. Unfortunately that wiki is not accessible without signing up for an account, so I&#8217;m posting the information here too.</p>
<h3>How to Install Computer Labs</h3>
<p>If you ever need to set up a large number of computers in identical configurations, you have a few options:</p>
<ul>
<li>Install each one individually by hand</li>
<li>Automate the standard install process, for example using:
<ul>
<li><a href="http://en.wikipedia.org/wiki/Windows_Automated_Installation_Kit">AIK</a> for Windows;</li>
<li><a href="https://help.ubuntu.com/7.04/installation-guide/i386/automatic-install.html">Kickstart</a> for Red Hat Linux, CentOS and Ubuntu; or</li>
<li><a href="http://people.freebsd.org/~dwhite/bsdconpaper.html">sysinstall and mfsroot</a> for FreeBSD.</li>
</ul>
</li>
<li>Configure one machine exactly how you like it, and then exactly duplicate the hard disk to the others (disk imaging)</li>
</ul>
<p>The first option (manual installation) is extremely slow, tedious, error-prone, unlikely to result in identical machines, and does not speed up future installations or reinstallations.</p>
<p>The second option requires using rarely-used and less tested parts of the installer, slows down badly with multiple simultaneous installations (due to limited network bandwidth and bugs in the inetd TFTP server), and places limits on what you can customise. For example, it seems impossible to customise <code>/etc/rc.conf</code> using the installer on FreeBSD, and pre-installing SSH keys is tricky. I spent days writing a <code>sysinstall</code> script to automate the process. It would have taken just half an hour to set one machine up perfectly by hand, and then copy the system image onto all the other PCs in a few unattended hours.</p>
<p>Therefore I prefer the third option, system imaging.</p>
<h3>What is System Imaging</h3>
<p>Imaging is the process of making exact copies of one machine&#8217;s hard disk, including all partitions, onto another. This only works when the second hard disk is at least as large as the first. It works best when all the PCs are identical.</p>
<p>Imaging is independent of the operating system. You can image Windows, FreeBSD, any version of Linux, dual-boot and triple-boot installations, whatever you like.</p>
<p>We successfully used imaging to set up the PCs for these workshops:</p>
<ul>
<li><a href="http://www.ws.afnog.org/afnog2009/">AfNOG 2009</a>, Cairo, all tracks</li>
<li><a href="http://oer.aptivate.org/wiki/KBT/BMO_Training_KENET">KENET BMO Training</a>, Nairobi 2009</li>
<li><a href="http://www.ws.afnog.org/afnog2010/">AfNOG 2010</a>, Kigali, for three tracks: SA-E, SS-E and SI-F</li>
</ul>
<h3>How to Image</h3>
<p>Many systems administrators have heard of <a href="http://www.symantec.com/norton/ghost">Norton Ghost</a> and <a href="http://www.acronis.com/homecomputing/products/trueimage/index.html">Acronis True Image</a>, two of the most popular commercial applications.</p>
<p>However, open source alternatives such as <a href="http://freshmeat.net/projects/g4l/">G4L</a> (Linux-based) and its ancestor <a href="http://www.feyrer.de/g4u/">G4U</a> (FreeBSD-based) are pretty good, and completely free. G4L however lacks a website, and it&#8217;s not obvious how best to use it, hence this post.</p>
<p>G4L is quite similar to G4U, and I could have used G4U instead. But I find the Linux kernel&#8217;s hardware support a bit better than FreeBSD&#8217;s, and G4L supports multicasting, which enables it to install many machines at the same time with good performance.</p>
<h3>Using Ghost for Linux (G4L)</h3>
<p>I&#8217;ve successfully used Ghost 4 Linux (G4L) versions 0.27 and 0.33 for this process. 0.33 has multicast support, which allows setting up an entire room in one go, without wasting network bandwidth copying the same 4 GB disk image to each of 50 machines independently.</p>
<p>Set up an FTP server on your network with an account that supports downloads and uploads (e.g. on a local server on your network). Make sure it has plenty of disk space free, perhaps 40 GB. Create an &#8220;img&#8221; directory under the FTP user&#8217;s home directory for the images.</p>
<p>Download G4L and burn some CDs, maybe about five copies, or set up network booting (this conflicts with FreeBSD PXE installation and may require BIOS setup changes to enable PXE).</p>
<p>It&#8217;s a good idea to explore G4L and get used to the options, but please <strong>be very careful</strong>, as it has the potential to wipe your hard disk! So please use a machine with a fresh hard disk or which you don&#8217;t mind wiping.</p>
<p>To boot into G4L (you will need to do this several times below, but not yet, unless you just want to explore):</p>
<ul>
<li>Reboot or power up the machine</li>
<li>Press the key to choose boot device</li>
<li>If CD-ROM is not on the list, reboot, go into the BIOS and enable booting from CD-ROM</li>
<li>Choose to boot from the CD</li>
<li>Choose the default kernel at the GRUB screen (just press Enter)
<ul>
<li>If for some reason the default kernel doesn&#8217;t work, the machine hangs or crashes or doesn&#8217;t detect the network interface, then try one or two other kernels</li>
</ul>
</li>
<li>Wait for the kernel and initrd to be loaded (two long lines of dots)</li>
<li>Then you can remove the CD, about one minute from cold boot, and start booting another PC</li>
<li>Press space to skip each of the information/advertising screens (about 8 of them)</li>
<li>Enter <code>g4l</code> at the prompt (if you go past this and get a shell, just type <code>g4l</code> at the shell prompt)</li>
<li>You can access other consoles with Ctrl-Alt-F1 to F4, log in as <code>g4l</code> with no password, and run <code>g4l</code>, <code>ifconfig</code>, <code>ping</code> or whatever</li>
<li>Choose <em>Network Use</em> (default)</li>
<li>Choose <em>Raw Mode</em> (default)</li>
<li>Check that you have an IP address (option B) or try again to acquire one by DHCP</li>
<li>If you can&#8217;t get an IP address by DHCP, check your cabling and DHCP server</li>
</ul>
<h3>Create a Restore Image (optional)</h3>
<p>Back up one of your PCs if necessary (if you plan to restore the PCs later) by:</p>
<ul>
<li>Follow the procedure above to get into Ghost for Linux</li>
<li>Enter the FTP server&#8217;s IP address, username and password</li>
<li>Choose an image name, e.g. <code>backup_original_2010_07_22.img</code></li>
<li>Choose the <em>back up</em> option</li>
<li>Press Space to select the entire disk (mark it with an asterisk [*])</li>
<li>Start backing up the image</li>
</ul>
<p>This process can take 1-2 hours. In the mean time&#8230;</p>
<h3>Set up the Master PC</h3>
<p>If you don&#8217;t already have a master computer set up, it&#8217;s a good idea to WIPE THE DISK first. This makes the image much smaller, and transfer much faster. Please DO NOT do this if you have anything valuable on the master computer, for example an existing operating system installation that you want to keep.</p>
<p>Boot G4L on the PC that you will use as the master. Use DD to wipe the entire disk with zeroes:</p>
<pre>
dd if=/dev/zero of=/dev/sda bs=1M
</pre>
<p>Install FreeBSD or whatever operating system(s) on the master PC, and set it up exactly the way you want all of the PCs to be. Examples include:</p>
<ul>
<li>Install Gnome (gnome/gnome2)</li>
<li>Install Xorg (x11/xorg)</li>
<li>Install Firefox (www/firefox35)</li>
<li>Install Xpdf (print/xpdf)</li>
<li>Enable gnome and sshd in <code>/etc/rc.conf</code>, and add templates for the IP address configuration (this saves typing when setting all the machines to static IPs):
<pre>
hostname="pc01.sse.ws.afnog.org"
ifconfig_bge0="dhcp"
# ifconfig_bge0="196.200.219.101/24"
defaultrouter="196.200.219.254"
gnome_enable="YES"
sshd_enable="YES"
</pre>
</li>
<li>Create a user account (e.g. username <code>afnog</code>, password <code>afnog</code>)</li>
<li>Log into Gnome, add firefox, terminal and the Downloads folder to your toolbar, and remove epiphany and evolution</li>
<li>Edit /etc/fstab and add the proc filesystem:
<pre>
proc /proc procfs rw 0 0
</pre>
<p>(this allows GDM to display the user list and shut down and restart the machine)</li>
<li>Edit /etc/profile and set the default pager to less by adding:
<pre>
PAGER=less; export PAGER
</pre>
</li>
<li>Set the timezone by softlinking <code>/etc/localtime</code> to something like /usr/share/zoneinfo/Africa/Kigali</li>
<li>Create <code>/etc/rc.local</code> and have it run <code>/usr/sbin/ntpd -qg</code> to set the time once at boot</li>
</ul>
<p>I recommend using DHCP on this machine. Otherwise all the imaged machines will boot up with the same IP address, causing IP address conflicts, and you will have to reconfigure them before you can access the Internet at all, or reconfigure them automatically.</p>
<p>Create some SSH keys for use in administering the machines. You may wish to set up the local server already and generate the keys there for security. I recommend adding the keys to <code>/root/.ssh/authorized_keys</code>. Please test that they work, and that sshd comes up automatically after boot!</p>
<h3>Imaging the other PCs</h3>
<p>On all the PCs (master and clones):</p>
<ul>
<li>Boot G4L as above</li>
<li>Check that it has an IP address (option B)</li>
</ul>
<p>Once a master is online, all the PCs will show &#8220;press any key to start&#8221;. Pressing any key on any computer will start all the machines imaging. If any PCs are not ready yet, you will have to cancel the imaging process on all of them and start again, or image those PCs later. So:</p>
<p><strong>Start the master last!</strong> (when all the other PCs are ready)</p>
<p>Start the clones first, by following these steps on each one:</p>
<ul>
<li>Choose UDP Multicast Client (option U)</li>
<li>Select the entire disk, <code>/dev/sda</code> with the space key</li>
<li>Say yes, you&#8217;re sure</li>
<li>When it says &#8220;Compressed UDP receiver&#8221;, it&#8217;s ready and waiting for a master to appear on the network</li>
</ul>
<p>Then start the master:</p>
<ul>
<li>Get ALL the clones ready, as above, before doing this!</li>
<li>On the master, choose UDP Multicast Server (option W)</li>
<li>Select the entire disk, <code>/dev/sda</code>, with the space key</li>
<li>Leave the options blank</li>
<li>Say yes, you&#8217;re sure</li>
<li>The master start accepting connections from clients, which will happen automatically. The screens on the clients will also change.</li>
<li>Please check that every client says &#8220;Press any key to start&#8221;.</li>
<li>If not, please check it for network problems, etc.</li>
<li><strong>DO NOT</strong> stop or kill the server now, unless you want to visit every client again!</li>
<li>You can press Ctrl+C <strong>on the client</strong> and run <code>g4l</code> again to check the IP address, retry DHCP, and try the UDP Multicast Client option again.</li>
<li>This is your last chance to join any remaining clients to the group for this imaging session!</li>
<li>When all the clients are ready, press a key on the master to start transfer.</li>
</ul>
<p>The master will show progress of the transfer, and an error line if any clients fail to respond. Clients that cause too many errors will be kicked out of the group and appear to &#8220;finish&#8221; early.</p>
<p>It&#8217;s difficult to tell if the imaging process finished successfully or failed on the clients. However it appears that FreeBSD is very good at detecting filesystem corruption, and will fail to boot if the image was not completely transferred. So you can test them by trying to boot FreeBSD and seeing if it boots completely or stops with a filesystem error. Ideally this would be improved in future versions of G4L.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/07/22/free-system-imaging-using-g4l/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Censorship Arms Race</title>
		<link>http://blog.aptivate.org/2010/04/07/the-censorship-arms-race/</link>
		<comments>http://blog.aptivate.org/2010/04/07/the-censorship-arms-race/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 13:00:57 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[Censorship]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=423</guid>
		<description><![CDATA[No security is perfect. There will always be ways around any security measure that we implement. However, no workaround is perfect either. Once we understand how it works, e.g. what the requests that it makes look like, we can block it. This quickly turns into an arms race between the user and the administrator.]]></description>
			<content:encoded><![CDATA[<p>Preface: This post discusses censorship. I want to be clear that I represent only my own personal views here, and I don&#8217;t personally support censorship in most cases. I think that freedom of access to information has a benefit and a cost, and the tradeoff depends on circumstances.</p>
<p>I think that censorship is useful when it serves a higher purpose, for example to save lives, or to save vital money for underfunded universities in countries where bandwidth is expensive and there are alternative ways for students to access the uncensored Internet for private browsing purposes. I&#8217;m opposed to censorship that requires leaving the country or changing your ISP to get around it.</p>
<p>Walubengo wrote on the BMO Training mailing list:</p>
<blockquote><p>Am just from the student labs and came across this sneaky little [software]:</p>
<p><a href="http://www.ninjacloak.com/">http://www.ninjacloak.com/</a></p>
<p>It basically allows my students to get behind the good old<br />
dansguardian/squid proxy_firewall; essentially allowing them to visit<br />
and download all and sundry (read porn, warez, torrents et al)</p>
<p>[H]ave been wondering why the clamour to &#8220;open-up&#8221; the internet &#8220;for<br />
research&#8221; had gone down (now I know).</p>
<p>Any quick counters? (beyond just blocking ninjacloak.com, since they are likely to get an equivalent sooner rather than later)</p></blockquote>
<p>I have never used ninjacloak and I don&#8217;t intend to, but I&#8217;m sure that if you post some logs of its use from your proxy server, we can figure out how to block it.</p>
<p>However, no security is perfect. There will always be ways around any security measure that we implement. However, no workaround is perfect either. Once we understand how it works, e.g. what the requests that it makes look like, we can block it.</p>
<p>This quickly turns into an arms race between the user and the administrator. The winner is usually the one with the most time, patience and determination. This may be a fight that you don&#8217;t want to take on.</p>
<p>In my view, if users really really want to access some blocked content, they will find a way. However, a good security system will make it possible to at least trace that they did so, if not exactly what they accessed. So my approach would be two-fold:</p>
<ol>
<li>Tackle the biggest problems first, and when they make sense. If someone uses ninjacloak to view a porn site once, it is hardly going to bring down your network, so you don&#8217;t need to care. If all your students are using TOR, AND it is bringing down your network, THEN it&#8217;s time to do something about it. If you don&#8217;t know what the biggest problem is, <a href="http://www.bwmo.net/pdf/chapter3.pdf">find out</a>.</li>
<li>Don&#8217;t forget that social measures are far more effective than technical ones. If students know that they are being watched, they are much less likely to try things like this. Make REALLY sure that everyone knows and understands your <a href="http://www.bwmo.net/pdf/chapter2.pdf">policy</a>. When you find students bypassing your security, <a href="http://www.bwmo.net/pdf/chapter7.pdf">go and talk to them</a>. If necessary, consider the use of formal sanctions, which are likely to have a stronger deterrent effect.</li>
</ol>
<p>If users think they are being treated unfairly or harshly, it can increase their determination to fight the system. If you have a good reason for censoring, because you can show them how much damage their actions are causing to legitimate or intended uses (such as academic research), they are much more likely to understand and comply with your requests, hopefully avoiding the need for sanctions.</p>
<blockquote><p>nb: but again, someone may ask, why not just open up the internet any way?</p></blockquote>
<p>Because (and only when) it wastes your precious bandwidth that&#8217;s better used for your core purpose (e.g. academic research), which is why you pay for the connection in the first place.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/04/07/the-censorship-arms-race/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Network Management Basics</title>
		<link>http://blog.aptivate.org/2010/04/07/network-management-basics/</link>
		<comments>http://blog.aptivate.org/2010/04/07/network-management-basics/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 07:43:20 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Censorship]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[university]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=419</guid>
		<description><![CDATA[I&#8217;ve been asked for some advice on how schools and universities can take advantage of the increased bandwidth available with the arrival of the TEAMS and EASSY submarine cables in East Africa. Management of Internet connections is a big subject. Whole books have been written about it, including the freely downloadable How To Accelerate Your [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been asked for some advice on how schools and universities can take advantage of the increased bandwidth available with the arrival of the <a href="http://en.wikipedia.org/wiki/TEAMS_(cable_system)">TEAMS</a> and <a href="http://en.wikipedia.org/wiki/EASSy_(cable_system)">EASSY</a> submarine cables in East Africa.</p>
<p>Management of Internet connections is a big subject. Whole books have been written about it, including the freely downloadable <a href="http://bwmo.net">How To Accelerate Your Internet (BMO Book)</a>. However, for anyone who doesn&#8217;t have time to read it, I will briefly summarise the most important points that I can think of:</p>
<ul>
<li>have a clear, simple and strict <a href="http://bwmo.net/pdf/chapter2.pdf">Internet access policy</a>, and enforce<br />
it.</li>
<li>have enough bandwidth, AT LEAST 3 kbps per computer, uncontended. So if you have 1000 computers, you should have 3 MBits dedicated bandwidth, or 60 MBps if it&#8217;s shared or contended with a 20:1 contention ratio (typical ISPs).</li>
<li>have competent network administrators. If you don&#8217;t have them, then hire or train them.</li>
<li>implement good network management practices, e.g. by following the advice of the <a href="http://bwmo.net/">BMO Book</a>.</li>
<li>start by <a href="http://bwmo.net/pdf/chapter5.pdf">solving</a> the problems that users complain most about, to give them the best possible service.</li>
<li><a href="http://bwmo.net/pdf/chapter3.pdf">monitor your network</a> to understand how Internet bandwidth is being used.</li>
<li><a href="http://bwmo.net/pdf/chapter4.pdf">block misuses</a> of Internet access that are causing problems for legitimate use of the Internet connection.</li>
<li>ensure that client PCs have good, fast antivirus, perform well, are<br />
regularly reformatted and reimaged, and have strong local security to prevent unauthorized software installation.</li>
</ul>
<p>Far more information on all of these topics can be found in the BMO book. I suggest starting with the <a href="http://bwmo.net/pdf/chapter1.pdf">Introduction</a> if you&#8217;re interested.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/04/07/network-management-basics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH Port Forwarding</title>
		<link>http://blog.aptivate.org/2010/03/10/ssh-port-forwarding/</link>
		<comments>http://blog.aptivate.org/2010/03/10/ssh-port-forwarding/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:22:47 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[forwarding]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[socks]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=240</guid>
		<description><![CDATA[SSH port forwarding is not hard to do, once you get your head around how it actually works. It's not like a VPN and it's not magic. It's quite like a proxy server.]]></description>
			<content:encoded><![CDATA[<p>David Sumbler <a href="http://mailman.linuxchix.org/pipermail/techtalk/2010-January/023958.html">wrote</a> to the LinuxChix mailing list:</p>
<blockquote><p>She now has two computers connected via an ADSL router.  Both computers run Ubuntu (8.06 and 9.10).  I have set things up so that I can log into the router, and also SSH to both computers simultaneously: I use two different port numbers&#8230;</p>
<p>I now want to be able to see her desktops, but I haven&#8217;t figured out how to do this. Having read the Gnome help, I believe that the Gnome remote desktop is inherently insecure: I would prefer to tunnel things over SSH, probably using vncserver and vncviewer (or perhaps Vinagre).</p>
<p>Can anybody explain what I need to do to get this to work, please?</p></blockquote>
<p>I get asked this kind of question so often that I thought I&#8217;d write it up somewhere so I could just point people to the post.</p>
<p>SSH port forwarding is not hard to do, once you get your head around how it actually works. Thanks to Alan for drawing this simple diagram:</p>
<p><a href="http://blog.aptivate.org/wp-content/uploads/2010/03/ssh-port-forwarding-diagram.jpg"><img src="http://blog.aptivate.org/wp-content/uploads/2010/03/ssh-port-forwarding-diagram.jpg" alt="" title="SSH Port Forwarding Diagram" width="548" height="277" class="alignnone size-full wp-image-410" /></a></p>
<p>SSH port forwarding is not like a VPN and it&#8217;s not magic. It&#8217;s quite like a proxy server:</p>
<ul>
<li>You tell SSH, with the <code>-L</code> option, to listen for connections on a port on your local side.</li>
<li>SSH connects to the remote host immediately as usual, and then starts listening on this port.</li>
<li>When it receives a connection on this port, it tells the other side (the SSH server that you connected to) to connect to the remote hostname and port that you specified.</li>
<li>If the remote side succeeds, the two SSH processes join the two sides together, forwarding bytes from each side to the other.</li>
</ul>
<p>(Note: it&#8217;s also possible to ask the remote SSH server to listen on a port on its side, with the <code>-R</code> option, and connect to a host and port on the client side, but in the interests of simplicity I will ignore that for today.)</p>
<p>I&#8217;ll show you the commands that I <a href="http://mailman.linuxchix.org/pipermail/techtalk/2010-January/023960.html">suggested</a> to David, and then explain what they do:</p>
<pre>ssh <strong>username</strong>@<strong>ip-address-of-ssh-server</strong> -p <strong>port1</strong> -L 5901:localhost:5900
ssh <strong>username</strong>@<strong>ip-address-of-ssh-server</strong> -p <strong>port2</strong> -L 5902:localhost:5900
vncviewer localhost:1 (connects to computer 1)
vncviewer localhost:2 (connects to computer 2)</pre>
<p>This opens two SSH connections, one to each of the machines behind his firewall, which are completely independent of each other. One SSH connection would actually be enough, as we will see in a minute, but this way fit more logically with my explanation.</p>
<p>These commands contain some placeholders that must be adapted to your situation:</p>
<dl>
<dt><strong>username</strong></dt>
<dd>The user name that you want to connect as. You can omit the name and the @ sign if it&#8217;s the same as your logged-in user on the client.</dd>
<dt><strong>ip-address-of-ssh-server</strong></dt>
<dd>The IP address or hostname of the SSH server that you want to connect to. In David&#8217;s case, he can&#8217;t see the SSH server directly, so he needs to use the public IP address of the router here, and the router will forward the port to the SSH server on his internal network.</dd>
<dt><strong>port1</strong> and <strong>port2</strong></dt>
<dd>David said that he can &#8220;SSH to both computers simultaneously [using] two different port numbers.&#8221; Presumably using port forwarding on his router. These are the two port numbers.</dd>
<dt><strong>vncviewer localhost:1</strong></dt>
<dd>This runs the VNC viewer on the client and tells it to connect to VNC display 1, which runs on port 5901 (by definition, VNC ports are display number plus 5900), which we already forwarded to computer 1 using SSH.</dd>
</dl>
<p>After running the two <code>ssh</code> commands command, the first SSH client will be listening on port 5901 on the machine that you run it on, and the second will be listening on port 5902.</p>
<p>After this, until you disconnect the SSH sessions or kill the clients in some way, whenever you connect to port 5901 on the client, it will tell the computer it&#8217;s connected to (computer 1) to connect to localhost port 5900 (that is, to its own VNC server) and then join the connections together, forwarding any data sent in either direction over the tunnel.</p>
<p>This part of the SSH command:</p>
<pre>-L 5902:localhost:5900</pre>
<p>tells the SSH client to <strong>L</strong>isten on port 5902 on the client, and when it receives a connection, to ask the other side (the server) to connect to (what it sees as) localhost port 5900, and SSH will forward communications between the two over the SSH tunnel.</p>
<p>Note first of all that we tell <code>vncviewer</code> to connect to <code>localhost</code>, not to the IP of the remote computer (internal or external). That&#8217;s because the client side of the SSH port forwarding is listening on <code>localhost</code> port 5901, and not any other IP address or port. If you connect to anything other than <code>localhost</code> port 5901, you will not end up talking to the local SSH client connected to <em>computer 1</em>.</p>
<p>Note secondly that when we created the tunnels, we told the ssh client to connect them to port 5900, also on localhost. This time, localhost is relative to the <strong>remote</strong> machine (the server), so we are telling it to connect to itself (<strong>not</strong> back to you). We could also specify any IP address and port that is reachable to the server, which is acting as our proxy in this case. However, we cannot specify an IP or port that is reachable to the client but not to the server, because the server will not be able to connect to it.</p>
<p>Now let&#8217;s imagine that we want to be able to VNC to both computers over a single SSH tunnel. We can do this by forwarding two different local ports, one to localhost, and one to the IP address of the other computer, like this:</p>
<pre>ssh <strong>username</strong>@<strong>ip-address-of-ssh-server</strong> -p <em>port1</em> -L 5901:localhost:5900 -L 5902:192.168.10.5:5900
vncviewer localhost:1 (connects to computer 1)
vncviewer localhost:2 (connects to computer 2)</pre>
<p>This assumes that computer 2 has the internal (RFC1918) IP address 192.168.10.5, and allows connections from computer 1 to its port 5900.</p>
<p>Port forwarding is unlike a VPN in several ways. The client does not end up with routing to the ultimate destination, nor does it need it. This means that it works even if the client and server have different views of the IP space, for example if they are located in subnets that use the same IP range to refer to different machines.</p>
<p>The server does not try to connect to the ultimate destination until the client receives an incoming connection (e.g. from <code>vncviewer</code> in this case). At this point, it may discover that there is nothing listening on the port to which it was told to connect, or that the destination host is down, or the port is blocked by a firewall. The server informs the client of this, but the client has no way to pass this information onto the connection that it received, which is has already accepted. All it can do is close the connection.</p>
<p>This means, for example, that if you were to sit at the server and type <code>vncviewer 192.168.10.5</code>, and that computer was not running VNC, you might get a <code>Connection refused</code> error. However, if you sit at the client and type <code>vncviewer localhost</code>, you will see the connection is opened and immediately closed, as though the VNC process was listening but refused to talk to you for some reason. Do not be fooled into assuming that VNC is running on the destination. With SSH port forwarding, you have no idea.</p>
<p>You cannot forward ICMP (pings), UDP sockets (DNS) or any other protocol except TCP using port forwarding, so you will never be able to ping remote hosts using this method alone.</p>
<p>It is currently impossible to add new forwarded ports to an existing connection or to change the ultimate destination host and port, so you must disconnect and reconnect with a new command line instead. This is inconvenient in some cases, especially where you have a long-running process open in the shell. I recommend using <code>ssh -N</code> to open an ssh client that does only port forwarding and not a shell; then open a separate shell if you need one.</p>
<p>The ssh client cannot exit while any connection is open, so if you log out with connections open, it will appear to hang. All open connections will be closed if the ssh client is forcibly killed by a signal or escape character.</p>
<p>If your port forwarding doesn&#8217;t appear to be working, check that you don&#8217;t have another process listening on the same port. For example, in the VNC case, both Gnome and KDE desktop sharing create a VNC server on the standard port, 5900, so you cannot forward the local port 5900 to anywhere if you have remote desktop access enabled on the client. The easiest solution is to listen on different port numbers, like 5901 and 5902, which correspond to VNC displays 1 and 2 in the command examples above.</p>
<p>Finally, please note that the meaning of commands like these is very different depending on where it is run (on the client or on the server):</p>
<pre>vncviewer localhost
vncviewer 192.168.10.5</pre>
<p>This is because:</p>
<ul>
<li>The meaning of <code>localhost</code> is different depending on where you run it (on the client or on the server); it always means connecting to the same computer that the command is running on.</li>
<li>The meaning of <code>192.168.10.5</code> (or any other IP address) similarly depends on where you run it (on the client or on the server); it is always relative to the computers that are reachable from the one running the command.</li>
<li>Connections always appear to the recipient to be coming from the computer running the command, so when the client or the server connects to 192.168.10.5, even if that&#8217;s the same computer for both, it will see the connections coming from different IP addresses.</li>
</ul>
<p>Tariq adds that you can also run:</p>
<pre>
ssh -D 9999 <strong>username</strong>@<strong>ip-address-of-ssh-server</strong>
</pre>
<p>where the <code>-D</code> option tells SSH to creates a <a href="http://en.wikipedia.org/wiki/SOCKS_(Protocol)">SOCKS</a> proxy server tunnel. You can then tell your web browser (and other clients with SOCKS support) to use localhost:9999 as a SOCKS proxy server. This will forward all your browsing through the SSH tunnel, which makes it look like you&#8217;re in a different location (e.g. to watch iplayer when not in the UK) and protects your unencrypted web browsing from random sniffers on public networks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/03/10/ssh-port-forwarding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Large Wireless Networks</title>
		<link>http://blog.aptivate.org/2010/01/05/wireless-networks-for-2000-clients/</link>
		<comments>http://blog.aptivate.org/2010/01/05/wireless-networks-for-2000-clients/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 21:23:07 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Appropriate Technology]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[AfNOG]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=233</guid>
		<description><![CDATA[I saw an interesting request on the AfNOG mailing list: How does one determine the number of users,  a wireless network can support. I need to buy a wireless router to support 2000 users within an organization. The problem is how do I determine this capability given the specs of the wireless router. To put it [...]]]></description>
			<content:encoded><![CDATA[<p>I saw an interesting <a title="Original message (request)" href="http://afnog.org/pipermail/afnog/2010-January/005696.html">request</a> on the AfNOG mailing list:</p>
<blockquote><p>How does one determine the number of users,  a wireless network can support. I need to buy a wireless router to support 2000 users within an organization. The problem is how do I determine this capability given the specs of the wireless router.</p>
<p>To put it in a better way &#8220;what determines the number of users a wireless router can support&#8221;[?]</p></blockquote>
<p>Although I&#8217;m not an expert on wireless networks, I have worked with them a bit, and I sent a <a title="My reply (post)" href="http://afnog.org/pipermail/afnog/2010-January/005697.html">reply</a> that might be useful to others (I hope).</p>
<p>I&#8217;m not sure there&#8217;s an easy answer to that question. Some factors that may influence the decision are:</p>
<ul>
<li>The total bandwidth available to a single wireless access point (AP), e.g. 54 MBps for an 802.11g router. This also depends on the level of 802.11 that the clients support. An 802.11b client will use much more airtime per packet than an 802.11g client, so if most of your clients are 802.11b then you won&#8217;t get more than 11MBps per AP, regardless of the theoretical maximum of the AP.</li>
<li>The frequency space available. There are only three non-overlapping 802.11b bands (maybe fewer for 802.11g), so no matter how many APs you have, the most bandwidth you could get in a given spot cannot be more than three times the bandwidth of one AP. Also, if they form a contiguous roaming network (same SSID and key) you have little or no control over which one a client will associate with, so you can&#8217;t evenly divide the available bandwidth between the three that you can see.</li>
<li>The guard time between different transmissions and for RTS/CTS round trips. This will cut your available bandwidth at least in half from the theoretical maximum, and more if you have hidden nodes (which is close to inevitable with thousands of clients, unless they are all in the same room).</li>
<li>The maximum number of clients that can associate with a given router. Most APs don&#8217;t publish this number, but Cradlepoint routers can handle <a href="http://www.cradlepoint.com/knowledge-base/maximum-clients-router">between 4 and 64 clients per router</a>. Keenan Systems <a href="http://www.keenansystems.com/wififaq.htm">reckons</a> that &#8220;Once you have more than 25 clients associated most access points start to break down&#8221;. I&#8217;d guess that Cisco kit has the highest limit, especially the professional versions (not Linksys branded) and el cheapo generic Chinese kit has the lowest.</li>
<li>If the AP is serving DHCP and running NAT (acting as a router as well as an AP) then the translation and DHCP tables of the router will be a limit. Some router DHCP servers only allow class C subnets, with a maximum of 253 usable client IP addresses per AP. It&#8217;s probably more advisable to use a real machine (with a hard disk) as a DHCP server.</li>
<li>Similarly, if you don&#8217;t do NAT on the AP, then whatever handles the NAT on your Internet gateway will see the IPs of the individual machines, and will therefore need to be able to handle however many simultaneous IPs your clients have, and connections that they make.</li>
<li>Whatever your DHCP server, the number of IPs available in your network subnet will limit the number of clients who can have a valid unique IP address at one time.</li>
<li>The bandwidth of your Internet connection. The minimum that I&#8217;ve seen working at all is 3kbps per client, or 6 MBps with 2000 clients. That should be real bandwidth, not contended upstream by the ISP, otherwise multiply by the contention ratio. Don&#8217;t forget to include your fixed clients as well.</li>
</ul>
<p>The best advice I can give you, never having built a wireless network this large myself, is to:</p>
<ul>
<li>Grit your teeth and buy the best kit you can find on the market. Be prepared to pay through the nose, e.g. $1000 per AP or more.</li>
<li>Talk to the manufacturers about the maximum number of associated clients, and get assurances in writing that their kit can handle the load. Preferably get them to propose a solution for 2000 clients, also in writing.</li>
<li>Use small cells with directional antennae and lots of APs in areas where you expect more than 10 clients at peak times.</li>
<li>Try to scale your network up smoothly rather than buying a complete solution in one go. Don&#8217;t try to support 2000 clients in the first year, let alone the first day.</li>
<li>Monitor and graph the performance of the network, particularly bandwidth, wireless contention, number of errors and number of associated clients, and identify hotspots.</li>
<li>Keep one or two APs spare, and deploy them in the areas that are seeing the most activity.</li>
</ul>
<p>Sunday Folayan <a title="Sunday Folayan's post" href="http://afnog.org/pipermail/afnog/2010-January/005698.html">wrote</a>:</p>
<blockquote><p>Must this network be implemented with JUST ONE wireless router? With one router &#8230; If you run 802.11bg at 2.4ghz, you have just about 2Mbps of bandwidth to play with, from one AP. If you deploy 802.11a at 5.8Ghz, you should get better than 10Mbps. If any of the clients is 802.11bg, the AP will default to 802.11bg, even if it is capable of 802.11a. With 2000 users, that is an average of 1Kbps or 5kbps at the best per subscriber! Could this be what you want?</p>
<p>To put it in a different way &#8230; One single AP cannot do it.</p></blockquote>
<p>And Hervey Allen <a title="Hervey Allen's post" href="http://afnog.org/pipermail/afnog/2010-January/005699.html">wrote</a>:</p>
<blockquote><p>From what I&#8217;ve experienced wireless router specifications and claims often do not match what you will experience in real-world use. I know of several large-scale installations (10,000+ users and above) who ended up using Cisco Aironet series routers with Power over Ethernet capabilities (PoE).</p>
<p>I will double-check, but last time I was on-site the upper limit for one of these wireless routers was around 50 concurrent users with light to moderate use. That is, a single user running a torrent can make an access point almost unusable for the other 49 potential users&#8230;</p>
<p>It would be interesting to hear from others on the list who have large wireless installations what their experience has been, and what hardware they have used.</p>
<p>Issues of giving out addresses, roaming, recapturing addresses, etc&#8230; are quite important.</p></blockquote>
<p>Patrick Okui wrote:</p>
<blockquote><p>Joel Ja did a pretty good <a href="http://nanog.org/meetings/nanog27/presentations/joel.pdf">presentation</a> on what he&#8217;s learned from setting up wifi installations for the various meetings/events at NANOG27. A few things have changed in the wifi world since 2003 but the concepts are still valid.</p></blockquote>
<p>Hamish Downer wrote in a comment to this post:</p>
<blockquote><p><a href="http://serverfault.com/questions/72767/why-is-internet-access-and-wi-fi-always-so-terrible-at-large-tech-conferences">This page</a> has some good answers. It is about tech conferences, but the basic problem of getting lots of people on wifi in a single space is covered by the solutions.</p></blockquote>
<p>I fully agree with Hamish, the page has excellent advice from people who have actually done this, unlike me.</p>
<p>Finally, Mark Tinka replied:</p>
<blockquote><p>I generally wouldn&#8217;t recommend vendors on a public mailing list in such variable matters as wireless deployments, but given the scale you&#8217;re considering, Aruba came to see me once (uninvited, as usual), and they seemed to have some rather interesting things to say re: their wireless product portfolio, with particular regard to <a href="http://www.arubanetworks.com/solutions/large_site.php">large scale installations</a>.</p>
<p>You might want to add them to your shopping list, but my guess is the price point is way-up-there, what with their controllers and all.</p>
<p>But be careful about &#8220;buying&#8221; everything they tell you (same goes for other vendors). As others have mentioned, binding assurances from them as well as PoC&#8217;s (proof of concept) before you sign would be great!</p></blockquote>
<p>I hope this helps someone. Please let us know how you get on.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/01/05/wireless-networks-for-2000-clients/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Backup Mail Exchangers</title>
		<link>http://blog.aptivate.org/2009/01/28/backup-mail-exchangers/</link>
		<comments>http://blog.aptivate.org/2009/01/28/backup-mail-exchangers/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 11:29:16 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Appropriate Technology]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bandwidth]]></category>

		<guid isPermaLink="false">http://tinderblog.wordpress.com/?p=78</guid>
		<description><![CDATA[On Monday night, the power supply unit (PSU) in the server that hosts our mail server failed at around 2200 GMT. We don&#8217;t have physical access to the server out of hours, so I wasn&#8217;t able to replace it until about 1045 the next day, so our main email server was down for nearly 13 [...]]]></description>
			<content:encoded><![CDATA[<p>On Monday night, the power supply unit (PSU) in the server that hosts our mail server failed at around 2200 GMT. We don&#8217;t have physical access to the server out of hours, so I wasn&#8217;t able to replace it until about 1045 the next day, so our main email server was down for nearly 13 hours.</p>
<p>We didn&#8217;t have a backup MX because:</p>
<ul>
<li>It usually can&#8217;t check whether recipients are valid or not, and therefore must accept mail that it can&#8217;t deliver;</li>
<li>It usually doesn&#8217;t have as good antispam checks as the primary, because it&#8217;s a hassle to keep it updated;</li>
<li>Spammers usually abuse backup MXes to send more spam, including Joe Jobs.</li>
</ul>
<p>I thought that this was OK because people who send us mail also have mail servers with queues, which should hold the mail until our server comes back up. It&#8217;s normal for mail servers to go down sometimes and this should not cause mail to be lost or returned.</p>
<p>However, we had a report that one of our users did not receive a mail addressed to them, and was told by the sender that it had bounced. I saw the bounce messsage and suspected Exchange, so I decided to check how long Exchange holds messages before bouncing them. Turns out it&#8217;s only five hours by default. Most mail servers hold mail for far longer, for example five days, sending a warning message back to the sender after one day.</p>
<p>Bouncing messages looks bad on us. Apart from making our main mail server more reliable <img src='http://blog.aptivate.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  we need a backup MX to accept mail when the master is down.</p>
<p>However I do still want to minimise the spam problem that this will cause. Therefore I configured our backup MX to only accept mail when the master is <strong>down</strong>. Otherwise it defers it, which will tell the sender to try sending it to the master (again).</p>
<p>How did I achieve this magic? With a little Exim configuration that took me a day and that I&#8217;m quite proud of. I set up a new virtual machine which just has Exim on it, nothing else. I configured it as an Internet host, and to relay for our most important domains. Then I created /etc/exim4/exim4.conf.localmacros with the following contents:</p>
<pre style="border:1px dashed #bbf;background-color:#ddf;padding:.5em;">CHECK_RCPT_LOCAL_ACL_FILE=/etc/exim4/exim4.acl.conf
callout_positive_expire = 5m</pre>
<p>This allows us to create a file called <tt>/etc/exim4/exim4.acl.conf</tt> which contains additional ACL (access control list) conditions. The other change, <tt>callout_positive_expire</tt>, I&#8217;ll describe in a minute.</p>
<p>I created <tt>/etc/exim4/exim4.acl.conf</tt> with the following contents:</p>
<pre style="border:1px dashed #bbf;background-color:#ddf;padding:.5em;"># if we know that the primary MX rejects this address, we should too
deny
        ! verify = recipient/callout=30s,defer_ok
        message = Rejected by primary MX

# detect whether the callout is failing, without causing it to
# defer the message. only a warn verb can do this.
warn
        set acl_m_callout_deferred = true
        verify = recipient/callout=30s
        set acl_m_callout_deferred = false

# if the callout did not fail, and the primary mail server is not
# refusing  mail for this address, then it's accepting it, so tell
# our client to try again later
defer
        ! condition = $acl_m_callout_deferred
        message = The primary MX is working, please use it

# callout is failing, main server must be failing,
# accept everything
accept
        message = Accepting mail on behalf of primary MX</pre>
<p>The first clause, which has a <tt>deny</tt> verb, does a callout to the recipient. A callout is an Exim feature which makes a test SMTP connection and starts the process of sending a mail, checking that the recipient would be accepted. This is designed to catch and block emails that the main server would reject. Our backup server has no idea what addresses are valid in our domains; only the primary knows that.</p>
<p>The callout response is cached for the default two hours if it returns a negative result (the recipient does not exist on the master) or five minutes (see <tt>callout_positive_expire</tt> above) if the address does exist. We use a <tt>defer_ok</tt> condition here so that if we fail to contact the master, we don&#8217;t defer the mail immediately, but instead assume that the address is OK and therefore continue to the next clause.</p>
<p>The second clause of the ACL,  which has a <tt>warn</tt> verb, is what took me so long to work out. Normally, if a condition in a statement returns a result of <em>defer</em>, which means that it failed, the server will defer the whole message (tell the sender to come back later). In almost all cases this is the right thing to do, but it&#8217;s the exact opposite of what we want here. We want to accept mail if the callout is failing, not defer it, otherwise our backup MX is useless (it stops accepting mail if the primary goes down).</p>
<p>Because this is such an unusual thing to do, there is no configurable option for it in Exim. The only workaround that I found is that there is exactly one way to avoid a deferring condition causing the message to be deferred: a <tt>warn</tt> verb. The <a title="Exim documentation" href="http://www.exim.org/exim-html-current/doc/html/spec_html/ch40.html#id623530">documentation for the warn verb</a> says:</p>
<blockquote><p>If any condition on a <span><strong class="option">warn</strong></span> statement cannot be completed (that is, there is some sort of defer), the log line specified by <span><strong class="option">log_message</strong></span> is not written&#8230; After a defer, no further conditions or modifiers in the <span><strong class="option">warn</strong></span> statement are processed. The incident is logged, and the ACL continues to be processed, from the next statement onwards.</p></blockquote>
<p>So what we do is:</p>
<ol>
<li>Set the local variable<br />
<tt>acl_m_callout_deferred</tt> to <em>true</em>;</li>
<li>Try the callout. If it defers (cannot contact the primary server) then we stop processing the rest of the conditions in the <strong>warn</strong> statement, as described above;</li>
<li>If we get to this point, we know that the callout did not defer, so we set <tt>acl_m_callout_deferred</tt> to <em>false</em>.</li>
</ol>
<p>The third clause  of the ACL,  which has a <tt>defer</tt> verb, simply checks the variable that we set above. If we get this far then the primary server is not rejecting this address; and if it&#8217;s not deferring either, then it must be accepting mail for the address. In that case, we defer the message, telling our SMTP client to try again later, at which point it will hopefully succeed in delivering directly to the primary.</p>
<p>Callout result caching becomes a problem here. If the master was not reachable, but a previous callout had verified that a particular address existed, and that callout result was cached for the default 24 hours, then the backup MX would defer subsequent mail to that address for the next 24 hours, even if the master went down. This is why we changed the positive callout result caching time to 5 minutes earlier.</p>
<p>The fourth clause  of the ACL,  which has an <tt>accept</tt> verb, is even simpler. It accepts everything that was not denied or deferred earlier. We can only get this far if the master is not accepting or rejecting mail for that address.</p>
<p>So far the configuration appears to work fine and has blocked 14 spam attempts (abusing the backup MX) in 14 hours.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2009/01/28/backup-mail-exchangers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fibre for Africa</title>
		<link>http://blog.aptivate.org/2008/09/26/fibre-for-africa/</link>
		<comments>http://blog.aptivate.org/2008/09/26/fibre-for-africa/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 10:38:03 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[africa infrastructure fibre undersea submarine cable network wireless microwave tier bandwidth]]></category>

		<guid isPermaLink="false">http://tinderblog.wordpress.com/?p=26</guid>
		<description><![CDATA[The consensus seems to be that Africa needs more land and submarine links to provide enough bandwidth for its long-term growth, and bring down satellite Internet costs. East Africa currently depends completely on expensive satellite bandwidth. There are several projects in progress to lay submarine cables down the east and west coasts, and it can [...]]]></description>
			<content:encoded><![CDATA[<p>The consensus seems to be that Africa needs more land and submarine links to provide enough bandwidth for its long-term growth, and bring down satellite Internet costs.</p>
<p>East Africa currently depends completely on expensive satellite bandwidth. There are several projects in progress to lay submarine cables down the east and west coasts, and it can be difficult to keep track of them all.</p>
<p>Luckily, Steve Song has drawn an excellent map <a title="Africa Undersea cables map" href="http://manypossibilities.net/2008/09/sub-saharan-africa-undersea-cables-in-2010-2/">here</a>. I&#8217;m linking it here to help people find it (including myself, next time I need that map).</p>
<p>We also need overland connections to help bring that bandwidth to landlocked countries, to help them share and compete with each other, and to network rural areas. Fibre, copper and microwave are the traditional and expensive options, O3B wants to provide a satellite alternative, but the <a href="http://tier.cs.berkeley.edu/wiki/Home">TIER group</a>&#8216;s <a href="http://tier.cs.berkeley.edu/wiki/Wireless">WiLDNet</a> project has the most disruptive potential in my view, potentially replacing microwave links with something that&#8217;s a hundred times cheaper and can be bought off the shelf.</p>
<p>TIER also wants to see their technology used to provide international bandwidth and compete with the undersea cables:</p>
<p><em>The vision is to connect Gilbraltar, which has low-cost world-class bandwidth and hosting, overland via long-distance Wifi through Morocco/Algerian, Mali, Burkina Faso, to Ghana.  This means crossing the Sahara, which is certainly not trivial.  (Timbuktu is roughly on this path.)  The article said 6 Mb/s, but I am thinking something much higher.  Although this is a crazy idea, I think it is much cheaper than many proposed projects, and if it worked you could grow the network over time and also increase BW for busy links, even moving to fiber once you have the traffic to pay for it.<br />
</em></p>
<p>(<a href="https://www.millennium.berkeley.edu/pipermail/tier/2008-June/001884.html">reference</a>, <a href="http://www.eetimes.com/news/latest/showArticle.jhtml;jsessionid=Y2QN4JAPNQB02QSNDLPSKH0CJUNN2JVN?articleID=208700017">video</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2008/09/26/fibre-for-africa/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

