<?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; linux</title>
	<atom:link href="http://blog.dest-unreach.be/tag/linux/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>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>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>Dropping the linux file cache</title>
		<link>http://blog.dest-unreach.be/2010/06/25/dropping-the-linux-file-cache</link>
		<comments>http://blog.dest-unreach.be/2010/06/25/dropping-the-linux-file-cache#comments</comments>
		<pubDate>Fri, 25 Jun 2010 08:25:41 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[memory]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1720</guid>
		<description><![CDATA[Sometimes, you want to manually alter the caching behaviour of linux. Making sure all data is committed to disk can be done by the sync command. If you want to flush the caches for reads as well, you need to go deeper into the system. echo 3 &#62; /proc/sys/vm/drop_caches Writing 1 only clears the pagecache; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.ksplice.com/2010/06/attack-of-the-cosmic-rays/">Sometimes</a>, you want to manually alter the caching behaviour of linux. Making sure all data is committed to disk can be done by the <em>sync</em> command. If you want to flush the caches for reads as well, you need to go deeper into the system.</p>
<blockquote>
<pre>echo 3 &gt; /proc/sys/vm/drop_caches</pre>
</blockquote>
<p>Writing 1 only clears the <a href="http://en.wikipedia.org/wiki/Page_cache">pagecache</a>; 2 clears the <a href="http://www.fieldses.org/~bfields/kernel/vfs.txt">dentries and inodes</a>; 3 clears all.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2010/06/25/dropping-the-linux-file-cache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get TBF back to work</title>
		<link>http://blog.dest-unreach.be/2010/03/10/how-to-get-tbf-back-to-work</link>
		<comments>http://blog.dest-unreach.be/2010/03/10/how-to-get-tbf-back-to-work#comments</comments>
		<pubDate>Wed, 10 Mar 2010 15:32:49 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[Ethernet]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1673</guid>
		<description><![CDATA[TBF or Token Bucket Filter is a tool from the linux kernel. It can be inserted as a &#8220;queueing discipline&#8221; for an Ethernet device. TBF is usually employed to limit the bandwidth. I tried to configure TBF on my Ubuntu 9.10 VMware box, but I got disappointing results: I only got around 100kbps, no matter [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lartc.org/howto/lartc.qdisc.classless.html#AEN691">TBF</a> or Token Bucket Filter is a tool from the linux kernel. It can be inserted as a &#8220;queueing discipline&#8221; for an Ethernet device. TBF is usually employed to limit the bandwidth.</p>
<p>I tried to configure TBF on my <a href="http://www.ubuntu.com/">Ubuntu</a> 9.10 <a href="http://www.vmware.com/">VMware</a> box, but I got disappointing results: I only got around 100kbps, no matter what I configured. I tried the same setup on a physical server, with the same results.</p>
<p><span id="more-1673"></span>After a full afternoon of experimenting and Googling, I was able to solve the issue by disabling offloading:</p>
<blockquote>
<pre># ethtool -k eth0
Offload parameters for eth0:
Cannot get device flags: Operation not supported
rx-checksumming: on
tx-checksumming: on
scatter-gather: on
tcp-segmentation-offload: on
udp-fragmentation-offload: off
generic-segmentation-offload: on
generic-receive-offload: off
large-receive-offload: off

# ethtool -K eth0 sg off
# ethtool -K eth0 tso off
# ethtool -K eth0 gso off

# ethtool -k eth0
Offload parameters for eth0:
Cannot get device flags: Operation not supported
rx-checksumming: on
tx-checksumming: on
scatter-gather: off
tcp-segmentation-offload: off
udp-fragmentation-offload: off
generic-segmentation-offload: off
generic-receive-offload: off
large-receive-offload: off
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2010/03/10/how-to-get-tbf-back-to-work/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Timestamping command output</title>
		<link>http://blog.dest-unreach.be/2009/12/25/timestamping-command-output</link>
		<comments>http://blog.dest-unreach.be/2009/12/25/timestamping-command-output#comments</comments>
		<pubDate>Fri, 25 Dec 2009 20:01:14 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1530</guid>
		<description><![CDATA[Sometimes it&#8217;s really useful to prepend a timestamp to every output line of a command. This can be done fairly easily: $command &#124; \ perl -pe '@now=localtime();printf "%04d-%02d-%02dT%02d:%02d:%02d ",$now[5]+1900,$now[4]+1,$now[3],$now[2],$now[1],$now[0];' The perl command reads in every line, prints the current time in the default format (or in whatever format you specify), followed by the read line.]]></description>
			<content:encoded><![CDATA[<p>Sometimes it&#8217;s really useful to prepend a timestamp to every output line of a command. This can be done fairly easily:</p>
<blockquote>
<pre>$command | \
p<!-- mod_security bypass -->erl -pe '@now=localtime();printf "%04d-%02d-%02dT%02d:%02d:%02d ",$now[5]+1900,$now[4]+1,$now[3],$now[2],$now[1],$now[0];'</pre>
</blockquote>
<p>The perl command reads in every line, prints the current time in the default format (or in whatever format you specify), followed by the read line.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2009/12/25/timestamping-command-output/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSL vhosts with Apache</title>
		<link>http://blog.dest-unreach.be/2009/11/29/ssl-vhosts-with-apache</link>
		<comments>http://blog.dest-unreach.be/2009/11/29/ssl-vhosts-with-apache#comments</comments>
		<pubDate>Sun, 29 Nov 2009 16:39:48 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Networking & Security]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1496</guid>
		<description><![CDATA[When hosting multiple sites on a single IP, HTTP1.1 has the necessary items on board to route the request to the correct site. This works because an HTTP 1.1 request includes a Host: header, which indicates to the server which site the client wishes to access. When using SSL-secured connections, this doesn&#8217;t work anymore. The [...]]]></description>
			<content:encoded><![CDATA[<p>When hosting multiple sites on a single IP, <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP1.1</a> has the necessary items on board to route the request to the correct site. This works because an HTTP 1.1 request includes a <a href="http://tools.ietf.org/html/rfc2616">Host: header</a>, which indicates to the server which site the client wishes to access.</p>
<p>When using SSL-secured connections, this doesn&#8217;t work anymore. The problem is similar to the situation in HTTP1.0: The server needs to know to which SSL-host the connection is addressed. <a href="http://en.wikipedia.org/wiki/Server_Name_Indication">SNI</a> introduces a similar solution: It specifies an extension to the SSL negotiation to indicate which server the client wishes to access.</p>
<p><span id="more-1496"></span>This extension opens up a small security hole: Since you send the server the expected hostname before the SSL negotiation starts, the server could, theoretically, generate a matching certificate on-the-fly. This certificate will probably be rejected by your browser, since it won&#8217;t be signed with a trusted root certificate. Another consideration is that the hostname you are connecting to is sent in plain text, before the secure channel is set up. However, a reverse lookup of the destination IP will usually return the same information.</p>
<p>Since SNI is an extension, support isn&#8217;t automatic. <a href="http://www.ubuntu.com/">Ubuntu</a> <a href="http://releases.ubuntu.com/karmic/">9.10 (Karmic)</a> supports SNI in apache out of the box. <a href="http://langui.sh/2009/11/03/ssl-vhosting-on-the-same-ip-aka-sni/">Paul Kehrer&#8217;s blog</a> has the full story, but it&#8217;s as simple as it seems:</p>
<blockquote>
<pre>NameVirtualHost *:443
&lt;VirtualHost *:443&gt;
    ServerAdmin webmaster@localhost
    DocumentRoot /my/doc/root
    ServerName mydomain.com
    SSLEngine On
    SSLCertificateFile /path/to/domain.crt
    SSLCertificateKeyFile /path/to/domain.key
&lt;/VirtualHost&gt;
&lt;VirtualHost *:443&gt;
    ServerAdmin webmaster@localhost
    DocumentRoot /my/doc/root
    ServerName mydomain2.com
    SSLEngine On
    SSLCertificateFile /path/to/domain2.crt
    SSLCertificateKeyFile /path/to/domain2.key
&lt;/VirtualHost&gt;</pre>
</blockquote>
<p>On the browser side, <a href="http://en.wikipedia.org/wiki/Server_Name_Indication#Browsers">Wikipedia has a list</a> of compatible browsers. Most notably:</p>
<ul>
<li>IE7 under XP does NOT support SNI</li>
<li>Mobile Safari on iPhone (3.0.2) does NOT support SNI</li>
</ul>
<p>Non-SNI compatible browsers will get the SSL certificate of the first vhost, which is probably wrong. You can require SNI-support by setting</p>
<pre>SSLStrictSNIVHostCheck on</pre>
<p>This will return a 403 to non-compliant browsers.</p>
<h3>Update 2010-07-01</h3>
<p>I just upgraded to iOS 4, which seems to have SNI-support (and IPv6 support as well)!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2009/11/29/ssl-vhosts-with-apache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving the buffer of &#8216;less&#8217; to file</title>
		<link>http://blog.dest-unreach.be/2009/11/11/saving-the-buffer-of-less-to-file</link>
		<comments>http://blog.dest-unreach.be/2009/11/11/saving-the-buffer-of-less-to-file#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:13:22 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MacOSX]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1359</guid>
		<description><![CDATA[I sometimes pipe a command to less to study it&#8217;s output. If it&#8217;s interesting enough, I re-run the command and redirect the output to file. This approach has some limitations: the command is run twice, possibly with different output. Obviously, I should use tee to send the output to both less and the file, but [...]]]></description>
			<content:encoded><![CDATA[<p>I sometimes pipe a command to less to study it&#8217;s output. If it&#8217;s interesting enough, I re-run the command and redirect the output to file. This approach has some limitations: the command is run twice, possibly with different output.</p>
<p>Obviously, I should use tee to send the output to both less and the file, but I regularly forget this. That where <a href="http://kerneltrap.org/node/17043">this hint</a> comes in: you can save the current less-buffer to file!</p>
<blockquote><p>In short, to save the buffer that is being displayed by a session of `less&#8217;, use its pipe-to-shell-command capability by scrolling to the top of the file and press `|&#8217; followed by `$&#8217; as well as entering `tee DESTINATION_FILE&#8217; when prompted for the shell command.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2009/11/11/saving-the-buffer-of-less-to-file/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a local repository in Ubuntu</title>
		<link>http://blog.dest-unreach.be/2009/08/17/using-a-local-repository-in-ubuntu</link>
		<comments>http://blog.dest-unreach.be/2009/08/17/using-a-local-repository-in-ubuntu#comments</comments>
		<pubDate>Mon, 17 Aug 2009 13:48:11 +0000</pubDate>
		<dc:creator>Niobos</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.dest-unreach.be/?p=1395</guid>
		<description><![CDATA[This is probably something everybody knows, but I&#8217;ve been Googling for this answer for over an hour: BASEDIR=/whatever cp $DEBs $BASEDIR/. mkdir -p $BASEDIR/dists/$DIST/$COMPONENT/binary-amd64 cd $BASEDIR apt-ftparchive packages . &#62; dists/$DIST/$COMPONENT/binary-amd64/Packages echo &#8220;deb file:$BASEDIR $DIST $COMPONENT&#8221; &#62;&#62; /etc/apt/sources.list apt-get update $BASEDIR is whatever directory you have space in (preferably an empty directory); $DIST and $COMPONENT [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably something everybody knows, but I&#8217;ve been Googling for <a href="http://cutecomputer.wordpress.com/2006/01/12/local-software-repository-for-apt-get/">this answer</a> for over an hour:</p>
<ul>
<li>BASEDIR=/whatever</li>
<li>cp $DEBs $BASEDIR/.</li>
<li>mkdir -p $BASEDIR/dists/$DIST/$COMPONENT/binary-amd64</li>
<li>cd $BASEDIR</li>
<li>apt-ftparchive packages . &gt; dists/$DIST/$COMPONENT/binary-amd64/Packages</li>
<li>echo &#8220;deb file:$BASEDIR $DIST $COMPONENT&#8221; &gt;&gt; /etc/apt/sources.list</li>
<li>apt-get update</li>
</ul>
<p>$BASEDIR is whatever directory you have space in (preferably an empty directory); $DIST and $COMPONENT are &#8220;jaunty-backports&#8221; and &#8220;main&#8221; in my setup, but you can vary.</p>
<p>You also might need to add the following line to /etc/apt/apt.conf to get rid of the &#8220;untrusted source&#8221; warning:</p>
<blockquote><p>APT::Get::AllowUnauthenticated &#8220;true&#8221;;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.dest-unreach.be/2009/08/17/using-a-local-repository-in-ubuntu/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

