<?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>Long-term Memory &#187; Networking &amp; Security</title>
	<atom:link href="http://blog.dest-unreach.be/category/networking-security/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.dest-unreach.be</link>
	<description>A collection of note-to-self&#039;s</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:05:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adding OpenVPN to dd-wrt mini</title>
		<link>http://blog.dest-unreach.be/2011/08/30/adding-openvpn-to-dd-wrt-mini</link>
		<comments>http://blog.dest-unreach.be/2011/08/30/adding-openvpn-to-dd-wrt-mini#comments</comments>
		<pubDate>Tue, 30 Aug 2011 17:18:16 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=2105</guid>
		<description><![CDATA[As described before, I chose to use the mini-build of dd-wrt on my Linksys WRT320N. Since I wanted OpenVPN support, I needed to add it myself. Installing I again used the openwrt modules, openvpn has its own package. There are, however, several dependencies: libssl.so.0.9.8 and libcrypto.so.0.9.8 from libopenssl liblzo2.so.2.0.0 (and symlinks) from liblzo I already had [...]]]></description>
			<content:encoded><![CDATA[<p>As described <a href="/2010/11/30/converting-a-wrt320n-to-dd-wrt">before</a>, I chose to use the <a href="http://www.dd-wrt.com/wiki/index.php/What_is_DD-WRT%3F#V24_pre_sp2_K26">mini-build</a> of dd-wrt on my Linksys WRT320N. Since I wanted <a href="http://openvpn.net/index.php/open-source.html">OpenVPN</a> support, I needed to add it myself.</p>
<h3>Installing</h3>
<p>I again used the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/">openwrt modules</a>, openvpn has its own <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/openvpn_2.0.9-5.1_mipsel.ipk">package</a>. There are, however, several dependencies:</p>
<ul>
<li><em>libssl.so.0.9.8</em> and <em>libcrypto.so.0.9.8</em> from <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/libopenssl_0.9.8i-3.2_mipsel.ipk">libopenssl</a></li>
<li><em>liblzo2.so.2.0.0</em> (and symlinks) from <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/liblzo_2.03-1_mipsel.ipk">liblzo</a></li>
</ul>
<p>I already had <em>libcrypto</em> <a href="/2010/12/06/using-nsupdate-in-dd-wrt">installed</a>, so I only needed 713kB of free space.</p>
<h3>Configuring</h3>
<p>Setup was fairly straightforward. Just make sure to do all heavy calculations on your desktop computer (i.e. generating keys). I installed the CA and host certificate into <em>/jffs/etc/ssl</em>, and added my openvpn-specific config files into <em>/jffs/etc/openvpn</em>. I did <a href="/wp-content/uploads/2011/08/verify-cn.sh">rewrite</a> the <em>verify-cn</em> script from perl to bash, since dd-wrt doesn&#8217;t come with perl.</p>
<p>Next, I wrote a very simple <a href="http://www.dd-wrt.com/wiki/index.php/Script_Execution">wanup script</a> to get openvpn (re)started at the appropriate time:</p>
<blockquote>
<pre># openvpn.wanup
if [ -e /tmp/openvpn.pid ] ; then
    kill -HUP `cat /tmp/openvpn.pid`
else
    /jffs/sbin/openvpn --cd /jffs/etc/openvpn --config server.conf --daemon --log /tmp/openvpn.log --writepid /tmp/openvpn.pid
fi</pre>
</blockquote>
<p>Obviously: don&#8217;t forget to add the corresponding configuration to the firewall.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/08/30/adding-openvpn-to-dd-wrt-mini/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring OpenVPN to support IPv6</title>
		<link>http://blog.dest-unreach.be/2011/06/27/configuring-openvpn-to-support-ipv6</link>
		<comments>http://blog.dest-unreach.be/2011/06/27/configuring-openvpn-to-support-ipv6#comments</comments>
		<pubDate>Mon, 27 Jun 2011 08:50:47 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[VPN]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=2070</guid>
		<description><![CDATA[As mentioned before, when switching to IPv6 (or more realistically, to dual stack) one of the things that might not work out of the box is VPNs. I decided to put some effort in it to get it to work anyway. Since we currently already have an OpenVPN tunnel, I preferred to stay with OpenVPN [...]]]></description>
			<content:encoded><![CDATA[<p>As <a href="/2011/06/14/world-ipv6-day-lessons-learned">mentioned before</a>, when switching to <a href="http://en.wikipedia.org/wiki/IPv6">IPv6</a> (or more realistically, to <a href="http://en.wikipedia.org/wiki/IPv6#Dual_IP_stack_implementation">dual stack</a>) one of the things that might not work out of the box is <a href="http://en.wikipedia.org/wiki/Virtual_private_network">VPN</a>s. I decided to put some effort in it to get it to work anyway.</p>
<p><span id="more-2070"></span>Since we currently already have an <a href="http://openvpn.net/index.php/open-source/overview.html">OpenVPN</a> tunnel, I preferred to stay with OpenVPN rather than switch to a different stack. Turns out OpenVPN supports IPv6, but under a series of assumptions. Among others, you need OpenVPN 2.3 on both the client and the server to be able to use the new config directives such as <em>route-ipv6</em>. At this moment, 2.3 is still beta. While I enjoy beta-software on a daily basis, rolling it out as a production VPN seems a bit to risky.</p>
<p>To provide maximal compatibility, I decided to stay with OpenVPN 2.2 and use the <a href="http://en.wikipedia.org/wiki/TUN/TAP">tap</a>-interface. I wrote my own up-scripts to take care of the required IPv6 configuration steps.</p>
<h3>Communicating the parameters</h3>
<p>OpenVPN has a <a href="http://openvpn.net/index.php/open-source/documentation/manuals/69-openvpn-21.html#lbAG"><em>setenv</em></a> config directive, which sets additional <a href="http://en.wikipedia.org/wiki/Environment_variable">environment variables</a> for the up-script. Its brother <em>setenv-safe</em> (which prefixes all variables with <em>OPENVPN_</em>) can also be pushed from server to client, allowing arbitrary parameters to be communicated from server to client. I use these three:</p>
<blockquote>
<pre>push "setenv-safe IP6_PREFIX 2001:db8:0:1::/64"
push "setenv-safe IP6_GW 2001:db8:0:1::1"
push "setenv-safe IP6_ROUTES '2001:db8:0:0::/48 2001:db8:1234::/48'"</pre>
</blockquote>
<h3>Configuring the client</h3>
<p>The client now has all the information it needs to enable IPv6 on the tunnel-connection. It just needs to apply that knowledge. I wrote some very basic shell scripts to accomplish this. Basically, the script looks for the <a href="http://en.wikipedia.org/wiki/MAC_address">MAC-address</a> of the (virtual) VPN interface, which it uses to form a <a href="http://en.wikipedia.org/wiki/IPv6#Stateless_address_autoconfiguration_.28SLAAC.29">SLAAC</a> address together with the supplied prefix. At this moment, it does not check for duplicate IP addressing. Next, it configures the calculated IP onto the interface and adds the supplied routes to the routing table.</p>
<p>For those interested, I provide, without any warranty &lt;insert legalese disclamer here&gt;</p>
<ul>
<li><a href="/wp-content/uploads/2011/06/up-macosx.sh">The MacOSX version</a>, written in bash</li>
<li><a href="/wp-content/uploads/2011/06/up-linux.sh">The Linux version</a>, written in bash</li>
<li><a href="/wp-content/uploads/2011/06/up-windows.cmd">The Windows version</a>, a batch-file and powershell hacked together</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/06/27/configuring-openvpn-to-support-ipv6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>World IPv6 day &#8211; lessons learned</title>
		<link>http://blog.dest-unreach.be/2011/06/14/world-ipv6-day-lessons-learned</link>
		<comments>http://blog.dest-unreach.be/2011/06/14/world-ipv6-day-lessons-learned#comments</comments>
		<pubDate>Tue, 14 Jun 2011 12:22:26 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[crypto]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[IPsec]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MacOSX]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=2032</guid>
		<description><![CDATA[Together with most of the internet, we tested IPv6 on World IPv6 day last week. I won&#8217;t go into details on what IPv6 is and why it&#8217;s important. Although IPv6 has been tested intensely in isolated networks, this is the first time it was tested on such a large scale. Technically, the participants would just [...]]]></description>
			<content:encoded><![CDATA[<p>Together with <a href="http://googleblog.blogspot.com/2011/01/world-ipv6-day-firing-up-engines-on-new.html">most</a> <a href="http://www.facebook.com/notes/facebook-engineering/world-ipv6-day-solving-the-ip-address-chicken-and-egg-challenge/484445583919">of</a> <a href="http://www.yahoo.com/">the</a> <a href="http://www.akamai.com/ipv6">internet</a>, we tested IPv6 on <a href="http://www.worldipv6day.org/">World IPv6 day</a> last week. I won&#8217;t go into details on what <a href="http://en.wikipedia.org/wiki/IPv6">IPv6</a> is and why it&#8217;s <a href="http://en.wikipedia.org/wiki/IPv6#Motivation_and_origins">important</a>. Although IPv6 has been tested intensely in isolated networks, this is the first time it was tested on such a large scale. Technically, the participants would just add <a href="http://en.wikipedia.org/wiki/IPv6_address#IPv6_addresses_in_the_Domain_Name_System">AAAA-records</a> for their websites to <a href="http://en.wikipedia.org/wiki/Domain_Name_System">DNS</a>. This small change causes a huge effect. Since most browsers are configured to prefer IPv6 AAAA-records over IPv4 A-records, this causes all IPv6-connected users to suddenly connect over IPv6 instead of IPv4.</p>
<p>For the most part, this major changeover happened without as much of a hitch. In fact, if I hadn&#8217;t known it was World IPv6 day, I wouldn&#8217;t have noticed anything. But I&#8217;m not a normal web-user, so I did notice some issues.</p>
<h3><span id="more-2032"></span>Where it did went wrong</h3>
<p>After some troubleshooting, they all boiled down to a single cause of oversight. They were not bugs or issues with IPv6 per se, just some &#8220;expected behavior&#8221; that we didn&#8217;t anticipate: IPv4-only VPNs.</p>
<p>Most servers in our datacenter are not publicly accessible; none of them are manageable over the public internet. In order to connect to them, you need a <a href="http://en.wikipedia.org/wiki/Virtual_private_network">VPN</a> connection. This serves multiple purposes: it secures all communication between client and server (so even plain-text http can be used securely to manage servers), it limits the number of users with access and most importantly (in the IPv4 world) it allows us to use <a href="http://www.apps.ietf.org/rfc/rfc1918.html">RFC1918 addresses</a> internally and still get the routing to work out. Technically it behaves an an extra (virtual) network card with a (virtual) cable connected straight to the datacenter. Additionally, some routes are configured automatically on the client to make sure traffic to the servers is sent over this &#8220;cable&#8221;.</p>
<p>We use two kinds of VPN-connections, but none of them was IPv6 enabled (i.e. could carry IPv6 data through the tunnel). Since by default client software prefers IPv6 connections, this caused the IPv6-internet connection to be preferred above the IPv4-VPN connection. Obviously, the firewall at the datacenter didn&#8217;t agree and refused access.</p>
<p>The solution was fairly obvious to state (enable IPv6 through the tunnels) but difficult to implement. In fact, I have not been able to get it to work well enough to install it on someone else&#8217;s computer.</p>
<h3>The attempts</h3>
<h4>IPsec in transport mode</h4>
<p>The &#8220;natural&#8221; solution would be to secure the IPv6 packets with <a href="http://en.wikipedia.org/wiki/IPsec">IPsec</a>, preferably in <a href="http://en.wikipedia.org/wiki/IPsec#Transport_mode">transport mode</a>, between the client and the firewall. Since there are no <a href="http://en.wikipedia.org/wiki/Network_address_translation">NAT</a>-issues, <a href="http://en.wikipedia.org/wiki/IPsec#Tunnel_mode">tunnel mode</a> is not required.</p>
<p><img class="alignnone size-full wp-image-2034" title="Network diagram" src="http://blog.dest-unreach.be/wp-content/uploads/2011/06/server-fw-client.png" alt="network diagram:  server (2001:db8:0:1::1) — (2001:db8:0:1::2) Firewall (2001:db8:1:0::2) — (2001:db8:1:1::3) client" width="700" height="143" /></p>
<p>However, I was not able to get this to work, even in manual keying mode (i.e. without <a href="http://en.wikipedia.org/wiki/Internet_Security_Association_and_Key_Management_Protocol">ISAKMP</a>). I couldn&#8217;t get <em>setkey</em> to accept the <em>src-dst</em> parameter in the SPD:</p>
<blockquote>
<pre># setkey -c
spdadd 2001:db8:0:1::1 2001:db8:1:1::3 any -P fwd ipsec esp/transport/2001:db8:1:0:2-2001:db8:1:1::3/require;
<em>^D</em>
# setkey -DP
2001:db8:0:1::1[any] 2001:db8:1:1::3[any] any
 fwd prio def ipsec
 esp/transport//require
 created: Jun 14 12:13:53 2011  lastused:                    
 lifetime: 0(s) validtime: 0(s)
 spid=1641 seq=1 pid=10485
 refcnt=1</pre>
</blockquote>
<p>This seems to be a Linux issue (Ubuntu 10.04 LTS with kernel 2.6.32-28-generic and ipsec-tools 0.7.1), since this does work on MacOSX (10.6.7).</p>
<h4>IPsec tunnel mode</h4>
<p>Since I&#8217;m not entirely sure that what I tried above (transport mode) is even supposed to work, I also tried tunnel mode. This worked, but is a pain to configure. I only tried manual keying, but using racoon to do username/password authentication will be even harder to explain to users…</p>
<p>The Mac built-in VPN client only supports &#8220;<a href="/2011/03/03/iphone-compatible-ipsec-vpn-on-an-ubuntu-server-with-ldap-authentication">Cisco IPsec</a>&#8220;. This uses the mode configuration stage to communicate the set of &#8220;networks&#8221; to tunnel (i.e. the SPD). However, according to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?racoon.conf+5+NetBSD-current">racoon.conf man-page</a>, I can only push IPv4 networks in the <em>split_network</em> directive.</p>
<h4>OpenVPN with tun driver</h4>
<p>According to the <a href="http://openvpn.net/index.php/open-source/faq/77-server/287-is-ipv6-support-plannedin-the-works.html">OpenVPN FAQ</a>, IPv6 is only supported if the underlying <a href="http://en.wikipedia.org/wiki/TUN/TAP">TUN-driver</a> supports it. The <a href="http://tuntaposx.sourceforge.net/">tuntaposx-page</a> does not mention IPv6 at all and hasn&#8217;t been updated for almost 2 years, so this seems unlikely to work.</p>
<p>Also, OpenVPN does not provide configuration directives to push IPv6 routes over from server to client.</p>
<h4>OpenVPN with tap driver</h4>
<p>Even when using the TAP-driver and <a href="http://en.wikipedia.org/wiki/IPv6#Stateless_address_autoconfiguration_.28SLAAC.29">router advertisements</a>, MacOSX does not seem to like enabling IPv6… Even after manually enabling it, MacOSX still doesn&#8217;t pick up its SLAAC address:</p>
<blockquote>
<pre># ifconfig tap0
tap0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
 ether 7e:95:80:00:90:0e
 inet 192.0.2.10 netmask 0xffffff00 broadcast 10.90.9.255
 open (pid 3847)

# ip6config start-v6 tap0
Starting IPv6 on tap0.

# sleep 60 # Wait for Router advertisement to show up

# ifconfig tap0
tap0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
 ether 7e:95:80:00:90:0e
 inet 192.0.2.10 netmask 0xffffff00 broadcast 10.90.9.255
 inet6 fe80::7c95:80ff:fe00:900e%tap0 prefixlen 64 tentative scopeid 0xa
 open (pid 3847)</pre>
</blockquote>
<p>And this still doesn&#8217;t allow me to push IPv6 routes to the clients upon connecting.</p>
<h3>The conclusion</h3>
<p>IPv6 is very stable and capable, but there are certain network-issues where there is still some work to do. If you happen to know a VPN-solution which supports IPv6 and works on Windows, linux and Mac, please let me know!</p>
<p>Edit: I <a href="/2011/06/27/configuring-openvpn-to-support-ipv6">worked out my own solution</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/06/14/world-ipv6-day-lessons-learned/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Getting a public IPv4 address with Belgacom&#8217;s BBox-2</title>
		<link>http://blog.dest-unreach.be/2011/04/12/getting-a-public-ipv4-address-with-belgacoms-bbox-2</link>
		<comments>http://blog.dest-unreach.be/2011/04/12/getting-a-public-ipv4-address-with-belgacoms-bbox-2#comments</comments>
		<pubDate>Tue, 12 Apr 2011 12:43:30 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[b-box2]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[Ethernet]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=2006</guid>
		<description><![CDATA[The new installs of Belgacom&#8217;s DSL internet connection are actually fairly descend. They provide a &#8220;b-box 2&#8221; which provides 2 wired 10/100base-T ports and an 802.11g access point. It consumes 10.1W of power once booted (21VA with a cosφ of .47, measured with 241Vac), which costs around €22/year at the current prices. The box has a [...]]]></description>
			<content:encoded><![CDATA[<p>The new installs of <a href="http://www.belgacom.be/private/en/jsp/dynamic/productCategory.jsp?dcrName=internet_l&amp;rid=B_CBUPREHPATNAinternet_EN">Belgacom&#8217;s DSL internet connection</a> are actually fairly descend. They provide a &#8220;<a href="http://support.en.belgacom.be/app/answers/detail/a_id/14453">b-box 2</a>&#8221; which provides 2 wired 10/100base-T ports and an <a href="http://en.wikipedia.org/wiki/IEEE_802.11g-2003">802.11g</a> access point. It consumes 10.1W of power once booted (21VA with a cosφ of .47, measured with 241Vac), which costs around €22/year at the current prices. The box has a built-in router which performs the <a href="http://en.wikipedia.org/wiki/PPPoE">PPPoE</a> connection and does the <a href="http://en.wikipedia.org/wiki/NAT">NAT</a>. While this setup is perfectly fine for a regular setup, obviously I wanted something more…</p>
<p><span id="more-2006"></span>So I wanted my own router to establish the PPPoE connection and obtain a public IPv4 address. It seems that even here the default setup of the b-box2 is good: PPPoE passthrough is enabled by default. This technique allows you to establish a PPPoE connection from the &#8220;LAN&#8221;-side of the router, effectively bypassing it. There are <span class="removed_link" title="http://patrick.vande-walle.eu/belgacom-bbox-2-tricks/bbox-2-in-bridge/">numerous posts</span> how to reconfigure the b-box into <a href="http://tools.ietf.org/html/rfc1483">RFC 1483 bridge-mode</a>, but this is not required! So just plugging in my router and configuring PPPoE on it was enough!</p>
<p>There are some finishing touches however that can be learned from the bridge-posts:</p>
<ul>
<li>I disabled my PPPoE connection on the b-box itself. I will not be using it, so there is no need to waste a public IPv4 address here.<br />
In the webinterface (http://192.168.1.1/ by default) go to <em>Advanced Settings</em> – <em>Network Interfaces</em>. Open the <em>Wan PPPoE</em> and <em>Disable</em> it, confirm by clicking <em>OK</em>.</li>
<li>I also disabled the built-in WiFi access point, since I have my own 802.11n access point right next to it. This is even <a href="http://support.en.belgacom.be/app/answers/detail/a_id/14608/~/how-do-i-disable-the-wireless-function-of-my-b-box2%3F">officially documented</a>.<br />
<em>Advanced Settings</em> – <em>Wireless</em> and click <em>Deactivate</em>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/04/12/getting-a-public-ipv4-address-with-belgacoms-bbox-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tail-ing logfiles with visual timing</title>
		<link>http://blog.dest-unreach.be/2011/03/09/tail-ing-logfiles-with-visual-timing</link>
		<comments>http://blog.dest-unreach.be/2011/03/09/tail-ing-logfiles-with-visual-timing#comments</comments>
		<pubDate>Wed, 09 Mar 2011 09:45:33 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[log]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1996</guid>
		<description><![CDATA[I regularly watch log files in real time using the highly appreciated tail -f command. But I usually find myself manually inserting newlines to give a visual clue of which log-lines happened together. Obviously the timestamps in the lines tell you the full story, but it&#8217;s not that visually appealing. So I wrote a very [...]]]></description>
			<content:encoded><![CDATA[<p>I regularly watch log files in real time using the highly appreciated <em>tail -f</em> command. But I usually find myself manually inserting newlines to give a visual clue of which log-lines happened together. Obviously the timestamps in the lines tell you the full story, but it&#8217;s not that visually appealing.</p>
<p><span id="more-1996"></span>So I wrote <a href="/wp-content/uploads/2011/03/logtail.pl">a very simple perl-script</a> that automates this for me. It behaves like <em>cat</em>, but inserts empty lines between input lines proportional to the amount of time between them. The numbers of lines inserted in logarithmically proportional to the elapsed time: one line for the first second, a second line for the next two seconds, a third line for the next 4 seconds, …</p>
<blockquote>
<pre>$ tail -f /var/log/mail.log | logtail.pl | sed 's/ .*//'
2011-03-09T10:33:02+01:00
2011-03-09T10:33:02+01:00
2011-03-09T10:33:02+01:00
2011-03-09T10:33:02+01:00
 
 
 
 
2011-03-09T10:33:36+01:00
2011-03-09T10:33:36+01:00
2011-03-09T10:33:36+01:00
 
 
 
 
2011-03-09T10:34:01+01:00
2011-03-09T10:34:01+01:00
 
 
 
 
 
2011-03-09T10:34:36+01:00
2011-03-09T10:34:36+01:00
2011-03-09T10:34:36+01:00
 
 
 
2011-03-09T10:34:48+01:00
2011-03-09T10:34:48+01:00
2011-03-09T10:34:48+01:00</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/03/09/tail-ing-logfiles-with-visual-timing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Postfix anti-spam configuration</title>
		<link>http://blog.dest-unreach.be/2011/03/08/my-postfix-anti-spam-configuration</link>
		<comments>http://blog.dest-unreach.be/2011/03/08/my-postfix-anti-spam-configuration#comments</comments>
		<pubDate>Tue, 08 Mar 2011 19:14:46 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1991</guid>
		<description><![CDATA[I assume I don&#8217;t have to introduce the concept of spam. Fighting spam can be done on different levels. A first line of defense is the mail server receiving them. There are several checks it can perform. Here is my configuration of Postfix. I chose to leave smtpd_client_restrictions, smtpd_helo_restrictions and smtpd_sender_restrictions blank and do all [...]]]></description>
			<content:encoded><![CDATA[<p>I assume I don&#8217;t have to introduce the concept of spam. Fighting spam can be done on different levels. A first line of defense is the mail server receiving them. There are several checks it can perform. Here is my configuration of Postfix.</p>
<p><span id="more-1991"></span>I chose to leave <em>smtpd_client_restrictions</em>, <em>smtpd_helo_restrictions</em> and <em>smtpd_sender_restrictions</em> blank and do all the checks in <em>smtpd_recipient_restrictions</em>. While it&#8217;s possible to reject messages earlier, this setup gives more info in the logs for rejected messages. These are the filters that I apply.</p>
<p>First, the local originated mail is allowed:</p>
<ul>
<li><em>permit_mynetworks</em>: Allow local originated mail</li>
</ul>
<p>Mail servers introduce themselves with their hostname. <a href="http://tools.ietf.org/html/rfc5321">RFC 5321</a> <a href="http://tools.ietf.org/html/rfc5321#section-2.3.5">requires</a> that all hostnames are fully qualified.</p>
<ul>
<li><em>reject_non_fqdn_hostname</em>: Non fully qualified hostnames names are rejected.<em></em></li>
<li><em>reject_invalid_hostname</em>: Hostnames which have an invalid syntax are rejected as well.</li>
</ul>
<p>The next phase in the SMTP conversation is identifying the sender. SMTP has an &#8220;envelope sender&#8221;. This is the address where bounces are returned to. Usually, this is the same as the &#8220;From&#8221; field, but this is not required. If my mailserver is to accept responsibility to deliver the mail, it should have a way to contact the sender. If the sender address is not usable, we can&#8217;t bounce if needed. Don&#8217;t accept responsibility in this case.</p>
<ul>
<li><em>reject_non_fqdn_sender</em></li>
<li>reject_unknown_sender_domain</li>
</ul>
<p>The same applies for the recipients:</p>
<ul>
<li><em>reject_non_fqdn_recipient</em></li>
<li><em>reject_unknown_recipient_domain</em></li>
</ul>
<p>The next statement is very important: don&#8217;t become an open relay. Only accept mail for the domains you&#8217;re actually responsible for:</p>
<ul>
<li><em>reject_unauth_destination</em></li>
</ul>
<p>The previous tests were local and fast. The mail-server can verify them with minimal effort. But this is not enough to fight spam. <a href="http://en.wikipedia.org/wiki/Greylisting">Greylisting</a> in particular is very effective. Greylisting will cause every mail to be initially rejected with a temporary failure. <a href="http://tools.ietf.org/html/rfc5321">RFC 5321</a> <a href="http://tools.ietf.org/html/rfc5321#section-4.5.4.1">requires</a> sending mail-servers to retry this delivery. On a second attempt, the message is accepted.</p>
<ul>
<li><em>check_policy_service inet:127.0.0.1:10023</em>: The greylisting server listens on this port and keeps the database of seen mails</li>
</ul>
<p><a href="http://en.wikipedia.org/wiki/Sender_Policy_Framework">SPF</a> is another anti-spam technique. This verifies that the sending mail-server is actually allowed to send mail <em>from</em> this email-address. However, this causes problems with standard forwarding of emails, so I don&#8217;t use it to reject messages, but I do log the result</p>
<ul>
<li><em>warn_if_reject, check_policy_service unix:private/policy-spf</em></li>
</ul>
<p>As a final test, several blacklists are checked. If the sending mail-server is listed as a known spammer, the mail is rejected.</p>
<ul>
<li><em>reject_rbl_client bl.spamcop.net</em></li>
<li><em>reject_rbl_client sbl-xbl.spamhaus.org</em></li>
<li><em>reject_rbl_client dnsbl.sorbs.net</em></li>
</ul>
<p>All previous configuration will either accept the mail for delivery, or reject the mail. It will not silently drop mail, which is a very important thing in my opinion. If you really want to, you can chain <a href="http://spamassassin.apache.org/">spamassassin</a> to the end.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/03/08/my-postfix-anti-spam-configuration/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iPhone compatible IPsec VPN on an Ubuntu server, with LDAP authentication</title>
		<link>http://blog.dest-unreach.be/2011/03/03/iphone-compatible-ipsec-vpn-on-an-ubuntu-server-with-ldap-authentication</link>
		<comments>http://blog.dest-unreach.be/2011/03/03/iphone-compatible-ipsec-vpn-on-an-ubuntu-server-with-ldap-authentication#comments</comments>
		<pubDate>Thu, 03 Mar 2011 09:53:13 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[IPsec]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1976</guid>
		<description><![CDATA[To get secure access to internal networks, one usually employs one of the many variants of a VPN. When connecting from a normal computer, you can install basically whatever variant you wish. When using devices such as smartphones however, the number of supported VPN technologies is usually limited. Especially on non-open platforms such as the [...]]]></description>
			<content:encoded><![CDATA[<p>To get secure access to internal networks, one usually employs <a href="http://openvpn.net/index.php/open-source/overview.html">one</a> <a href="http://en.wikipedia.org/wiki/Point-to-Point_Tunneling_Protocol">of</a> <a href="http://en.wikipedia.org/wiki/IPsec">the</a> <a href="http://www.cisco.com/en/US/docs/ios/12_4t/12_4t11/htwebvpn.html">many</a> <a href="http://en.wikipedia.org/wiki/Secure_Shell">variants</a> of a <a href="http://en.wikipedia.org/wiki/Virtual_private_network">VPN</a>. When connecting from a normal computer, you can install basically whatever variant you wish. When using devices such as smartphones however, the number of supported VPN technologies is usually limited. Especially on non-open platforms such as the iDevices by Apple, you can not add VPN software yourself, contrary to the <a href="http://www.android.com/">Android</a> platform.</p>
<p>In this post, I&#8217;ll explain how to set up an IPsec (without L2TP) tunnel endpoint on an Ubuntu server, capable of handling an iPhone/iPad/iPod/iWhatever. The users will be authenticated against an LDAP directory.</p>
<h3><span id="more-1976"></span>Packages</h3>
<p><a href="http://en.wikipedia.org/wiki/IPsec">IPsec</a> usually consists of two parts: the IPsec layer itself and the <a href="/2009/05/27/ipsec-isakmp-negotiation-opened-up">IKE layer</a> on top. IPsec itself is usually implemented in the kernel. It handles all encryption, decryption and authentication of the packets, based on the set of security policies (SP) and security associations (SA). Since you usually don&#8217;t want to setup these SA&#8217;s and SD&#8217;s yourself, Internet Key Exchange (IKE) comes into play. IKE is usually implemented in user space. In this post, I&#8217;ll be describing <a href="http://ipsec-tools.sourceforge.net/">racoon</a>.</p>
<p>The standard <a href="http://packages.ubuntu.com/lucid/racoon">Ubuntu racoon package</a> does not have LDAP support compiled in. So I pulled in the source, changed the <em>./configure</em> line to include <em>&#8211;with-libldap</em> and rebuild the package. Since I have no experience whatsoever with packaging, I will have <a href="/wp-content/uploads/2011/03/racoon-ldap_0.7.1-1.6ubuntu1_amd64.deb">made</a> more mistakes that you can dream off.</p>
<h3>Racoon configuration</h3>
<p>The <em>racoon.conf</em> file has different sections, each with their own purpose. The listen group specifies the IP&#8217;s to bind on. By default racoon listens on any IP. The path directives tell racoon where to find its other configuration files.</p>
<blockquote>
<pre>listen {
 isakmp 192.0.2.1 [500];
 isakmp_natt 192.0.2.1 [4500];
}
path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";</pre>
</blockquote>
<p>Next up is a <em>remote</em> section, specifying the phase 1 settings. Normal IPsec tunnels are point-to-point. You can configure the tunnel statically on both ends. Here we are setting up a roaming tunnel: we don&#8217;t know where the client is. This has some implications:</p>
<ul>
<li>the server can never initiate the connection (since the IP of the client(s) are unknown)</li>
<li>The client&#8217;s tunnel-IP needs to be assigned from the server. This minimizes client-side configuration</li>
<li>The client must authenticate itself using a username/password combo.</li>
</ul>
<blockquote>
<pre>remote anonymous { # Do not filter on source IP, anyone can connect to this tunnel
 passive on; # Don't initiate, only listen
 exchange_mode main,aggressive; # Accept both modes
 my_identifier fqdn "vpn.example.net"; # Identify ourselves with this name
 mode_cfg on; # configure the client's IP address using mode configuration
 verify_cert off; # Don't check client certificate
 ike_frag on; # Announce IKE-fragmentation support
 generate_policy on; # automatically install SPD's
 nat_traversal on; # Support NAT traversal
 dpd_delay 20; # Disconnect dead clients after 20 seconds
 proposal { # Phase 1 parameters
  encryption_algorithm aes;
  hash_algorithm sha1;
  authentication_method xauth_psk_server; # Require PreSharedKey group authentication and username/password user authentication
  dh_group 2;
 }
}</pre>
</blockquote>
<p>Next section is the mode configuration. This is sometimes called phase 1.5, because it happens between phase 1 and phase 2. In this step, the client is authenticated.</p>
<blockquote>
<pre>mode_cfg {
 auth_source ldap; # Authenticate against LDAP
 save_passwd on; # Allow users to save passwords

 group_source ldap; # Verify group membership in LDAP
 auth_groups "ipsec vpn";  # Require users to be member of this group in order to connect

 network4 10.0.0.0;  # Give clients addresses starting from this address
 pool_size 255;  # up to 255 addresses higher

 split_network include 10.1.0.0/16; # split tunneling, only tunnel traffic to these subnets
}

ldapcfg {
 host "ldap.example.net";
 base "dc=example,dc=net";
 subtree on;
 bind_dn ""; # Anonymous simple bind
 bind_pw "";
 attr_user "uid";  # Searches for (&lt;attr_user&gt;=&lt;userid&gt;)
 attr_group "cn";  # Searches for (&amp;(&lt;attr_group&gt;=&lt;groupname&gt;)(&lt;attr_member&gt;=&lt;userid&gt;))
 attr_member "member";
}</pre>
</blockquote>
<p>The <em>sainfo</em> section specifies the parameters to use for phase 2, the actual data-encryption:</p>
<blockquote>
<pre>sainfo anonymous {
 encryption_algorithm aes;
 authentication_algorithm hmac_sha1;
 compression_algorithm deflate;
}</pre>
</blockquote>
<p>Next, you need to add the group-name and the group password to the <em>psk.txt</em> file:</p>
<blockquote>
<pre>iOStunnel     $ecr3tPassW0rd</pre>
</blockquote>
<h3>iPhone configuration</h3>
<p>The iPhone is set up fairly easily: Under Settings -&gt; General -&gt; Network -&gt; VPN, you need to <em>Add VPN Configuration</em>:</p>
<ul>
<li>Select a (Cisco) <em>IPsec</em> tunnel</li>
<li>The <em>Description</em> can be whatever you want</li>
<li><em>Server</em> should be the FQDN of your server, this is checked against the <em>my_identifier</em> in the server config</li>
<li><em>Account</em> and <em>Password</em> are the credentials of the user in the LDAP database</li>
<li><em>Group Name</em> and <em>Secret</em> are the group credentials as specified in the <em>psk.txt</em> file</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2011/03/03/iphone-compatible-ipsec-vpn-on-an-ubuntu-server-with-ldap-authentication/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Using nsupdate in dd-wrt</title>
		<link>http://blog.dest-unreach.be/2010/12/06/using-nsupdate-in-dd-wrt</link>
		<comments>http://blog.dest-unreach.be/2010/12/06/using-nsupdate-in-dd-wrt#comments</comments>
		<pubDate>Mon, 06 Dec 2010 18:17:06 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1954</guid>
		<description><![CDATA[dd-wrt has built-in support for a whole list of Dynamic DNS services. Unfortunately, they only support HTTP-based services. I use a standard RFC2136 DNS update. Here&#8217;s how to add nsupdate support to dd-wrt. Installing I again used the openwrt modules, nsupdate is contained within bind-client. There are, however, several dependencies: libbind9.so.40.0.3, libdns.so.43.0.0, libisc.so.41.1.0, libisccc.so.40.0.0, libisccfg.so.40.0.3, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dd-wrt.com/wiki/index.php/What_is_DD-WRT%3F">dd-wrt</a> has built-in support for a whole list of <a href="http://en.wikipedia.org/wiki/Dynamic_DNS">Dynamic DNS</a> services. Unfortunately, they only support HTTP-based services. I use a standard <a href="http://tools.ietf.org/html/rfc2136">RFC2136</a> DNS update. Here&#8217;s how to add <a href="http://en.wikipedia.org/wiki/Nsupdate">nsupdate</a> support to dd-wrt.</p>
<h3><span id="more-1954"></span>Installing</h3>
<p>I again used the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/">openwrt modules</a>, <em>nsupdate</em> is contained within <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/bind-client_9.5.0-P1-1.1_mipsel.ipk">bind-client</a>. There are, however, several dependencies:</p>
<ul>
<li><em>libbind9.so.40.0.3</em>, <em>libdns.so.43.0.0</em>, <em>libisc.so.41.1.0</em>, <em>libisccc.so.40.0.0</em>, <em>libisccfg.so.40.0.3</em>, <em>liblwres.so.40.0.0</em> (and symlinks) from <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/bind-libs_9.5.0-P1-1.1_mipsel.ipk">bind-libs</a></li>
<li><em>libcrypto.so.0.9.8</em> from <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/libopenssl_0.9.8i-3.2_mipsel.ipk">libopenssl</a></li>
</ul>
<p>These are some serious libraries, takeing up 2.7MB of free space…</p>
<h3>Configuring</h3>
<p>I tried to use <a href="http://tools.ietf.org/html/rfc2137#section-4">SIG(0)</a>, but that failed. <em>nsupdate</em> complains about a missing symbol &#8216;flockfile&#8217;. So I settled for <a href="http://en.wikipedia.org/wiki/TSIG">TSIG</a> authentication. Since this is a post about dd-wrt, I&#8217;ll assume the sever is already set up and tested (<a href="http://www.ops.ietf.org/dns/dynupd/secure-ddns-howto.html">this</a> will guide you through if it&#8217;s not), so I&#8217;ll go straight to the config files:</p>
<p><em>/jffs/etc/ddns.key</em>:</p>
<blockquote>
<pre>fqdn.of.key. 0huPr3nqFnxUETlrM/VxGg==</pre>
</blockquote>
<p><em>/jffs/etc/config/ddns-update.wanup</em>:</p>
<blockquote>
<pre>#!/bin/sh

# wanup scripts seem to run without LD_LIBRARY_PATH set
export LD_LIBRARY_PATH='/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/jffs/usr/local/lib:/mmc/lib:/mmc/usr/lib:/opt/lib:/opt/usr/lib'

# wanup scripts have the IPLOCAL variable set, but cron does not
if [ -z "$IPLOCAL" ]; then
 IPLOCAL=`ip addr sh dev ppp0 | grep 'inet ' | cut '-d ' -f6`
fi

sleep 30 # wait for IPv6, DNS, … to stabilize

echo -e "server ddns.master.server.fqdn\nkey `cat /jffs/etc/ddns.key`\n
update delete fqdn.to.set A\nupdate delete fqdn.te.set TXT\n
update add fqdn.to.set 300 A $IPLOCAL\nupdate add fqdn.to.set 300 TXT `date "+%Y-%m-%d_%H:%M:%S"`\n
send" | /jffs/bin/nsupdate
</pre>
</blockquote>
<p>I cut that last echo-line into pieces for readability, make sure that it&#8217;s one single line (from <em>echo</em> all the way to <em>nsupdate</em>).</p>
<p>I added the following line to the <em>Additional cron jobs</em> on the webinterface. Contrary to the <a href="http://www.dd-wrt.com/wiki/index.php/CRON">dd-wrt wiki page</a>, <em>/jffs/etc/crontab</em> does not seem to work. This will run the <em>ddns-update</em> script every hour, at 5 minutes past the hour:</p>
<blockquote>
<pre>5 * * * *  root  /jffs/etc/config/ddns-update.wanup
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2010/12/06/using-nsupdate-in-dd-wrt/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding IPv6 support to dd-wrt</title>
		<link>http://blog.dest-unreach.be/2010/12/05/adding-ipv6-support-to-dd-wrt</link>
		<comments>http://blog.dest-unreach.be/2010/12/05/adding-ipv6-support-to-dd-wrt#comments</comments>
		<pubDate>Sun, 05 Dec 2010 17:54:47 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[IPv6]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1935</guid>
		<description><![CDATA[Although the big builds of dd-wrt contain IPv6 support, it doesn&#8217;t support ip6tables. Hence, I choose to use the mini build (which gives me the most free space) and add the missing parts myself. I shamelessly used OpenWRT modules to save me the trouble of figuring out how to compile each library. (Unfortunately, my router [...]]]></description>
			<content:encoded><![CDATA[<p>Although the <a href="http://www.dd-wrt.com/wiki/index.php/What_is_DD-WRT%3F#K2.6_Build_Features">big</a> builds of dd-wrt contain IPv6 support, it doesn&#8217;t support ip6tables. Hence, I choose to use the mini build (which gives me the most free space) and add the missing parts myself. I shamelessly used <a href="http://www.openwrt.org/">OpenWRT</a> modules to save me the trouble of figuring out how to compile each library. (Unfortunately, my router isn&#8217;t supported by OpenWRT, so I need to stay with dd-wrt for the base system).</p>
<h3><span id="more-1935"></span>Kernel support</h3>
<p>Unfortunately, I couldn&#8217;t use the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/">OpenWRT kamikaze 8.09.2</a> kernel modules, since they&#8217;re build for a different kernel. <a href="/2010/12/01/compiling-custom-dd-wrt-kernel-modules">My previous post</a> explains how I compiled the modules myself. I stripped and installed:</p>
<ul>
<li>ipv6.ko : the main IPv6 module</li>
<li>sit.ko : IPv6-in-IPv4 tunneling, for <a href="http://www.sixxs.net/">Sixxs</a> support</li>
<li>ip6_tables.ko : IPv6 firewalling, main module</li>
<li>ip6table_filter.ko : IPv6 firewalling, filtering module</li>
<li>nf_conntrack_ipv6.ko : Connection tracking for IPv6</li>
<li>ip6t_REJECT.ko : Reject target for ip6tables</li>
<li>Additional matching modules: ip6t_frag.ko, ip6t_hbh.ko, ip6t_hl.ko, ip6t_ipv6header.ko, ip6t_rt.ko</li>
</ul>
<h3>Radvd</h3>
<p><a href="http://www.litech.org/radvd/">radvd</a> is responsible for communicating the presence of a router. Hosts can automatically configure an IPv6 address in the correct range and know what gateway to use to the rest of the world. I simply used the radvd binary that shipped with the big build of dd-wrt and dropped that in to /jffs/sbin/.</p>
<p>The configuration file looks like this: /jffs/etc/radvd.conf</p>
<blockquote>
<pre>interface br0 {
    AdvSendAdvert on;
    MaxRtrAdvInterval 600;
    AdvManagedFlag off;
    AdvOtherConfigFlag off;
    prefix 2001:db8:0:0::/64 {
        AdvAutonomous on;
        AdvValidLifetime 604800;
        AdvPreferredLifetime 86400;
    };
};
interface br1 {
    AdvSendAdvert on;
    MaxRtrAdvInterval 600;
    AdvManagedFlag off;
    AdvOtherConfigFlag off;
    prefix 2001:db8:0:1::/64 {
        AdvAutonomous on;
        AdvValidLifetime 604800;
        AdvPreferredLifetime 86400;
    };
};</pre>
</blockquote>
<p>Obviously, put your own prefixes in there!</p>
<h3>Ip6tables</h3>
<p>Since I like to keep my setup as lean as possible, I choose not to use ipkg and only copy the files that are actually used by dd-wrt; ipkg also installs the scripts that OpenWRT uses. Hence, I needed to manually keep track of the dependencies. To get ip6tables working, I installed:</p>
<ul>
<li><em>ip6tables</em> binary from the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/ip6tables-utils_1.4.0-1_mipsel.ipk">ip6tables-utils</a> package</li>
<li>all <em>libip6t_</em>* libraries from the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/ip6tables-utils_1.4.0-1_mipsel.ipk">ip6tables-utils</a> package</li>
<li>the <em>libxt_</em>* libraries from the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/iptables_1.4.0-1_mipsel.ipk">iptables</a> package</li>
<li><em>libxt_state.so</em> from the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/iptables-mod-conntrack_1.4.0-1_mipsel.ipk">iptables-mod-conntrack</a> package</li>
</ul>
<h3>Debugging tools</h3>
<p>I also installed <em>ping6</em> (from <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/iputils-ping6_20071127-1_mipsel.ipk">iputils-ping6</a>) and <em>traceroute6</em> (from <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/iputils-traceroute6_20071127-1_mipsel.ipk">traceroute6</a>) to aid in debugging IPv6 connectivity.</p>
<h3>Aiccu</h3>
<p>To get a working <a href="http://www.sixxs.net/">Sixxs</a> tunnel, they provide a small tool called <a href="http://www.sixxs.net/tools/aiccu/">AICCU</a>. This tool automatically configures the tunnel and keeps it alive. I just used the <em>aiccu</em> binary from the <a href="http://downloads.openwrt.org/kamikaze/8.09.2/brcm47xx/packages/aiccu_20070115-2.1_mipsel.ipk">aiccu</a> package.</p>
<p>I use a fairly basic configuration file: aiccu.conf</p>
<blockquote>
<pre>username &lt;your nichandle/username&gt;/Txxxxx
password &lt;your password&gt;
protocol tsp
tunnel_id Txxxxx
server tic.sixxs.net
ipv6_interface sit_sixxs
daemonize true
automatic true
requiretls false</pre>
</blockquote>
<p>I use a standard IPv6-in-IPv4 (SIT) tunnel, so I added a corresponding hole in my firewall:</p>
<blockquote>
<pre>iptables -A INPUT -p 41 -j ACCEPT</pre>
</blockquote>
<h3>Setup</h3>
<p>To get this all up and running, I added a few script in <em>/jffs/etc/config: ipv6.startup</em> (run at bootup):</p>
<blockquote>
<pre>insmod /jffs/kmods/ipv6.ko
insmod /jffs/kmods/sit.ko
insmod /jffs/kmods/ip6_tables.ko
insmod /jffs/kmods/ip6table_filter.ko
insmod /jffs/kmods/nf_conntrack_ipv6.ko

echo 1 &gt; /proc/sys/net/ipv6/conf/all/forwarding

ip -6 addr add 2001:db8:0:0:0011:22ff:fe33:4455/64 dev br0
ip -6 addr add 2001:db8:0:1:0011:22ff:fe33:4456/64 dev br1

/jffs/sbin/radvd -C /jffs/etc/radvd.conf</pre>
</blockquote>
<p>and <em>ipv6.wanup</em> (run after the WAN and firewall are up):</p>
<blockquote>
<pre>ntpclient europe.pool.ntp.org   # aiccu requires a correct clock, so make sure our clock is set
/jffs/sbin/aiccu start /jffs/etc/aiccu.conf</pre>
</blockquote>
<p>As a finishing touch, I added my IPv6 address in DNS.</p>
<h3>Firewall</h3>
<p>Since IPv6 does not offer the automatic traffic blocking that NAT does, an IPv6 firewall is a must. Here is my very basic script, which I put in <em>firewall.wanup</em></p>
<blockquote>
<pre>ip6tables -F INPUT
ip6tables -F FORWARD
ip6tables -X

ip6tables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT
ip6tables -A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT
ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT
ip6tables -A INPUT -i br0 -j ACCEPT
ip6tables -A INPUT -i br1 -p icmpv6 --icmpv6-type router-solicitation -j ACCEPT
ip6tables -P INPUT DROP

ip6tables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
ip6tables -A FORWARD -p icmpv6 --icmpv6-type echo-request -j ACCEPT
ip6tables -A FORWARD -i br0 -j ACCEPT
ip6tables -A FORWARD -i br1 -o sit_sixxs -j ACCEPT
ip6tables -P FORWARD DROP</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2010/12/05/adding-ipv6-support-to-dd-wrt/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Compiling custom dd-wrt kernel modules</title>
		<link>http://blog.dest-unreach.be/2010/12/01/compiling-custom-dd-wrt-kernel-modules</link>
		<comments>http://blog.dest-unreach.be/2010/12/01/compiling-custom-dd-wrt-kernel-modules#comments</comments>
		<pubDate>Wed, 01 Dec 2010 18:12:20 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[dd-wrt]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[WRT320N]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1905</guid>
		<description><![CDATA[Since none of the dd-wrt releases include ip6tables support, I added it myself. The standard kernel does support module loading, so you can simply add additional kernel features without reflashing the device. You do need some writable storage. I use the remaining 4MB of flash using JFFS, but using an external storage (USB, network, &#8230;) [...]]]></description>
			<content:encoded><![CDATA[<p>Since none of the dd-wrt releases include ip6tables support, I added it myself. The standard kernel does support module loading, so you can simply add additional kernel features without reflashing the device. You do need some writable storage. I use the remaining 4MB of flash using <a href="http://en.wikipedia.org/wiki/JFFS">JFFS</a>, but using an external storage (USB, network, &#8230;) is also possible.</p>
<p>Since you can&#8217;t run a complete build environment on the router itself, you&#8217;ll have to set up a <a href="http://en.wikipedia.org/wiki/Cross_compiler">cross-compiling</a> environment on your own machine. As I found out, this isn&#8217;t always very easy to do&#8230;<br />
<span id="more-1905"></span></p>
<p>Since there are some requirements on the development host (<a href="http://www.jonisdumb.com/2011/02/dd-wrt-cross-compile-environment.html">64bit host</a>, <a href="http://www.dd-wrt.com/wiki/index.php/Development#Pre-requisites">case-sensitive filesystem</a>), I used a clean Ubuntu-64bit 10.04 install in a virtual machine.</p>
<h3>Preparations</h3>
<p>Start by getting the sources for the 2.6.24.111 kernel:</p>
<blockquote>
<pre># svn checkout svn://svn.dd-wrt.com/DD-WRT/src/linux/brcm/linux-2.6.23 -r 14929
# head -n5 linux-2.6.23/Makefile
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 24
EXTRAVERSION = .111
NAME = Arr Matey! A Hairy Bilge Rat!</pre>
</blockquote>
<p>See, I told you it&#8217;s 2.6.24.111!</p>
<p>Next we&#8217;ll get the <a href="http://www.dd-wrt.com/wiki/index.php/Development#Building_DD-WRT_from_Source">cross-compiling toolchain</a>:</p>
<blockquote>
<pre># cd /opt
# wget http://www.dd-wrt.com/dd-wrtv2/downloads/others/sourcecode/toolchains/current-toolchains.tar.bz2
# tar jxvf current-toolchains.tar.bz2</pre>
</blockquote>
<h3>Configuring the kernel</h3>
<p>First some cleanup to do: I don&#8217;t need the madwifi drivers, so I remove their reference. The config.h file is a broken softlink, so I remove that as well. For some reason, <em>jhash2.h</em> is not included (presumably because <em>jhash.h</em> is included first). This causes <em>JHASH_GOLDEN_RATIO</em> not to be defined. There are probably nicer ways to solve this, but I just redefine the constant outside of the <em>#ifndef</em>&#8216;s</p>
<blockquote>
<pre># grep -v madwifi drivers/net/wireless/Kconfig &gt; drivers/net/wireless/Kconfig.new
# mv drivers/net/wireless/Kconfig{.new,}
#
# rm include/linux/config.h
#
# echo "#define JHASH_GOLDEN_RATIO    0x9e3779b9" &gt;&gt; include/linux/jhash2.h</pre>
</blockquote>
<p>Next configure the options you want, starting from dd-wrt&#8217;s default:</p>
<blockquote>
<pre># cp .config_std .config
# make menuconfig
# PATH=$PATH:/opt/toolchain-mipsel_gcc4.1.2/bin make modules</pre>
</blockquote>
<h3>Stripping the modules</h3>
<p>Now just cherry-pick the modules you want. If you really want to squeeze out every last byte, you can strip each individual module:</p>
<blockquote>
<pre># /opt/toolchain-mipsel_gcc4.1.2/bin/mipsel-linux-strip --strip-unneeded ipv6.ko</pre>
</blockquote>
<p>Then copy these modules onto your router and <em>insmod</em> them, probably in a script.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2010/12/01/compiling-custom-dd-wrt-kernel-modules/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

