<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>khax.net &#187; Ubuntu</title>
	<atom:link href="http://blog.khax.net/tag/ubuntu/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.khax.net</link>
	<description>Adventures in Ubuntu systems administration</description>
	<lastBuildDate>Thu, 08 Jul 2010 02:01:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.khax.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/6ccca40b5ab19d33d91882e4d8f9a9c4?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>khax.net &#187; Ubuntu</title>
		<link>http://blog.khax.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.khax.net/osd.xml" title="khax.net" />
	<atom:link rel='hub' href='http://blog.khax.net/?pushpress=hub'/>
		<item>
		<title>Odd iproute2 gateway behavior with two gateways</title>
		<link>http://blog.khax.net/2010/01/26/odd-iproute2-gateway-behavior-with-two-gateways/</link>
		<comments>http://blog.khax.net/2010/01/26/odd-iproute2-gateway-behavior-with-two-gateways/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:40:35 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[iptroute2]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=169</guid>
		<description><![CDATA[After helping a frustrated yet patient Elvar I thought I better post about the situation we came across incase anybody else finds themselves in the same situation. Elvar started with all the correct elements to setup a functioning multrouting gateway. Two connections from two different providers, eth1, eth2. Running on an Ubuntu box with eth0 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=169&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After helping a frustrated yet patient Elvar I thought I better post about the situation we came across incase anybody else finds themselves in the same situation.</p>
<p>Elvar started with all the correct elements to setup a functioning multrouting gateway. Two connections from two different providers, eth1, eth2. Running on an Ubuntu box with eth0 as internal. Both internet connections working on their own.</p>
<p>But alas. Whenever both eth1 and eth2 were active on the host, outgoing packets just would not go out. I don&#8217;t know if incoming packets were being replied to as we were unable to check that.</p>
<p>If just eth1 or eth2 was active than everything traversed ok. But we wanted it to work with both connections.</p>
<p>After a LONG time of diagnosing we noticed there were two default routes in iproute2 (ip&#8217;s fudged, but you get the idea):</p>
<pre>firewall# ip route show
...
default via 1.1.2.1 dev eth2  metric 100
default via 1.1.3.1 dev eth1  metric 100</pre>
<p>My firewall often has two default routes listed on the main table (ppp0, and ppp1) until the cleanup script fixes it. Without any negative side effect. I may just be lucky though.</p>
<p>Upon removing the eth2 line from table main, everything started working correctly. Incoming, outgoing, forwarding, balancing.</p>
<p>I also noticed the output of ifconfig eth2 looked a bit screwed too, but there was not much we could do about that as it was assigned by dhcp.</p>
<pre>eth2      Link encap:Ethernet  HWaddr 00:11:22:33:44:55
    inet addr:1.1.2.1  Bcast:255.255.255.255  Mask:255.255.255.0</pre>
<p>See it? No not the MAC address. The broadcast address. A quick ipcalc 1.1.2.1/24 gives me a broadcast of 1.1.2.255. But once we removed the eth2 default route line, it all started working again and didn&#8217;t get to dig into it to see if the broadcast actually affected it.</p>
<p>So that&#8217;s all. Just remember there are a lot more things to go wrong in a multigateway setup, including things outside of iptables.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=169&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2010/01/26/odd-iproute2-gateway-behavior-with-two-gateways/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Iptables packet flow diagram</title>
		<link>http://blog.khax.net/2009/12/07/iptables-packet-flow-diagram/</link>
		<comments>http://blog.khax.net/2009/12/07/iptables-packet-flow-diagram/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 23:39:18 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iproute2]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=167</guid>
		<description><![CDATA[Here is the diagram I keep stuck to my wall for reference when dealing with iptables. I cannot remember what site I used as a reference when creating the diagram. The original was an ascii chart though. This is created in dia and exported to pdf too. Both attached for convenience. CC licensed as long as the original [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=167&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is the diagram I keep stuck to my wall for reference when dealing with iptables.</p>
<p>I cannot remember what site I used as a reference when creating the diagram. The original was an ascii chart though. This is created in dia and exported to pdf too. Both attached for convenience. CC licensed as long as the original chart I copied allows it.</p>
<h2>Packet flow examples:</h2>
<h3>All packets to or from localhost travel down the left side of the chart.</h3>
<p>From external destination localhost: PREROUTING -&gt; INPUT -&gt; [Local Process] -&gt; OUTPUT -&gt; POSTROUTING.</p>
<p>From localhost destination external: OUTPUT -&gt; POSTROUTING -&gt; [External Host] -&gt; PREROUTING -&gt; INPUT.</p>
<h3>All forwarded packets travel the right side of the chart and travel all three tables coming in and then again going out.</h3>
<p>From external dest internal: PREROUTING -&gt; FORWARD -&gt; POSTROUTING.</p>
<p>Internal response to external: PREROUTING -&gt; FORWARD -&gt; POSTROUTING.</p>
<p>and so forth.</p>
<p>This is what caught me for a while. Forwarded packet travel the right side route and get out of (or in to) the network. The response then gets generated and does not start from FORWARD or POSTROUTING, but from PREROUTING again. So all NEW forwarded packets need to be marked in PREROUTING and the mark saved. Not new packets need that mark restored in PREROUTING, and all packets need that mark restored in POSTROUTING. (As demonstrated by my previous post).</p>
<p>Locally generated traffic only sees OUTPUT and POSTROUTING before hitting the network and needs to be marked before hitting POSTROUTING, hence the OUTPUT chain rules in my previous post.</p>
<p>I will accept changes to the chart too if anybody wants modifications made.</p>
<p><a href="http://dl.dropbox.com/u/173699/iptables%20routing.dia">iptables routing.dia</a></p>
<p><a href="http://dl.dropbox.com/u/173699/iptables%20routing.pdf">iptables routing.pdf</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=167&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/12/07/iptables-packet-flow-diagram/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Multi gateway balancing with iptables</title>
		<link>http://blog.khax.net/2009/12/01/multi-gateway-balancing-with-iptables/</link>
		<comments>http://blog.khax.net/2009/12/01/multi-gateway-balancing-with-iptables/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 02:14:06 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[multi]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=163</guid>
		<description><![CDATA[I have been testing load balancing via both iptables and ip route nexthop for a couple of days now.  They both work pretty well too. This only balances outgoing traffic as incoming traffic balanced via DNS RR and the firewall just returns the traffic on the interface it arrived on as per the previous post. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=163&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been testing load balancing via both iptables and ip route nexthop for a couple of days now.  They both work pretty well too.</p>
<p>This only balances outgoing traffic as incoming traffic balanced via DNS RR and the firewall just returns the traffic on the interface it arrived on as per the previous post.</p>
<p>On the whole, I prefer the iptables solution. It seems to balance the traffic better. ip route balances outgoing connections based on nexthop of the route to that host is not already in it&#8217;s routing cache. While iptables balances traffic by alternate outgoing connections. The only downside I have seen is occasional connection drops to the BlackBerry servers.</p>
<p>After 24 hours of iptables balancing:</p>
<pre>ppp0      Link encap:Point-to-Point Protocol
          RX bytes:1186783900 (1.1 GB)  TX bytes:1290603327 (1.2 GB)
ppp1      Link encap:Point-to-Point Protocol
          RX bytes:1109227490 (1.1 GB)  TX bytes:1140565429 (1.1 GB)
</pre>
<p>&nbsp;</p>
<p>This is using inclusion rules for determining balanced traffic. These are the rules that ended up on the production server:</p>
<p>&nbsp;</p>
<pre># Load balancing rules (Split 50/50 between fwmark 1/2)
iptables -t mangle -A balance1 -d 192.168.0.0/16      -j RETURN
iptables -t mangle -A balance1 -d 10.0.0.0/8          -j RETURN
iptables -t mangle -A balance1 -m connmark ! --mark 0 -j RETURN
iptables -t mangle -A balance1 -m state --state ESTABLISHED,RELATED -j RETURN
iptables -t mangle -A balance1 -m statistic --mode nth --every 2 --packet 0 -j CONNMARK --set-mark 1
iptables -t mangle -A balance1 -m statistic --mode nth --every 2 --packet 1 -j CONNMARK --set-mark 2

# Check to see if we have already marked a packet
iptables -t mangle -A PREROUTING  -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
iptables -t mangle -A OUTPUT      -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark

# Mark incoming connections to return on the interface they came in on
iptables -t mangle -A PREROUTING          -i ppp0                     -m state --state NEW  -j CONNMARK --set-mark 1
iptables -t mangle -A PREROUTING          -i ppp1                     -m state --state NEW  -j CONNMARK --set-mark 2

# New outgoing packets
iptables -t mangle -A PREROUTING  -i eth0          -p tcp --dport  22 -m state --state NEW  -j balance1
iptables -t mangle -A PREROUTING  -i eth0          -p tcp --dport  25 -m state --state NEW  -j balance1
iptables -t mangle -A PREROUTING  -i eth0          -p tcp --dport  80 -m state --state NEW  -j balance1
iptables -t mangle -A PREROUTING  -i eth0          -p tcp --dport 443 -m state --state NEW  -j balance1
iptables -t mangle -A OUTPUT                       -p tcp --dport  80 -m state --state NEW  -j balance1

# Choose our route and save the mark
iptables -t mangle -A PREROUTING  -m connmark --mark 1 -j MARK --set-mark 1
iptables -t mangle -A PREROUTING  -m connmark --mark 2 -j MARK --set-mark 2
iptables -t mangle -A PREROUTING  -m state --state NEW -m connmark ! --mark 0  -j CONNMARK --save-mark
</pre>
<p>&nbsp;</p>
<p>That&#8217;s all of the CONNMARK and MARK related rules I use.</p>
<p>The new outgoing packets section is where I choose what packets should be balanced and accounts for about 95% of our outgoing traffic.</p>
<p>The balance1 chain just has some checks at the beginning to catch further traffic that should not be balanced in case some rule gets messed up.</p>
<p>Of the new outgoing packets rules, the PREROUTE lines are for forwarded traffic and the OUTPUT rule is for traffic generated on that host by a transparent squid proxy.</p>
<p>Hope somebody finds that useful one day.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=163&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/12/01/multi-gateway-balancing-with-iptables/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Multi gateway routing with iptables and iproute2</title>
		<link>http://blog.khax.net/2009/11/28/multi-gateway-routing-with-iptables-and-iproute2/</link>
		<comments>http://blog.khax.net/2009/11/28/multi-gateway-routing-with-iptables-and-iproute2/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 07:39:08 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=160</guid>
		<description><![CDATA[Notes on multi gateway routing with iptables and iproute2, suggestions and corrections gladly accepted. My notes may be incomplete or just plain wrong, I pieced them together after getting it working. Running on Ubuntu-9.10 with two internet connections ppp0 and ppp1 both with static IP&#8217;s from two different internet providers in Australia (iiNet and Internode). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=160&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Notes on multi gateway routing with iptables and iproute2, suggestions and corrections gladly accepted. My notes may be incomplete or just plain wrong, I pieced them together after getting it working.</p>
<p>Running on Ubuntu-9.10 with two internet connections ppp0 and ppp1 both with static IP&#8217;s from two different internet providers in Australia (iiNet and Internode).</p>
<h2>Preperation:</h2>
<p>Extra ip route tables per gateway.</p>
<p>Add tables to /etc/iproute2/rt_tables. Table names and numbers can be anything as long as they are consistent later on.</p>
<pre>echo -e "101 connection1\n102 connection2" | sudo tee -a /etc/iproute2/rt_tables
</pre>
<p>Add routes to the extra rule tables. Copy the local routes from the main table then add the default gateway specific to this connection. Replace the vars at the beginning with your relevant settings.</p>
<pre>#!/bin/sh
DEV1=ppp0
IP1=100.0.1.1
GW1=100.0.1.254
TABLE2=connection2
DEV2=ppp1
IP2=100.0.2.1
GW2=100.0.2.254
ip route flush table $TABLE1
ip route flush table $TABLE2
ip route show table main | grep -Ev '(^default|ppp)' | while read ROUTE ; do
    ip route add table $TABLE1 $ROUTE
    ip route add table $TABLE2 $ROUTE
done
ip route add table $TABLE1 $GW1 dev $DEV1 src $IP1
ip route add table $TABLE2 $GW2 dev $DEV2 src $IP2
ip route add table $TABLE1 default via $GW1
ip route add table $TABLE2 default via $GW2
</pre>
<p>ip route output:</p>
<pre>~# ip route show
100.0.1.254 dev ppp0  proto kernel  scope link  src 100.0.1.1
100.0.2.254 dev ppp1  proto kernel  scope link  src 100.0.2.1
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.1
default via 100.0.1.254 dev ppp0
</pre>
<pre>~# ip route show table connection1
100.0.1.254 dev ppp0  proto kernel  scope link  src 100.0.1.1
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.1
default via 100.0.1.254 dev ppp0

~# ip route show table connection2
100.0.2.254 dev ppp1  proto kernel  scope link  src 100.0.2.1
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.1
default via 100.0.2.254 dev ppp1
</pre>
<p>Add the ip rules:</p>
<pre>ip rule add from 100.0.1.1 lookup connection1
ip rule add from 100.0.2.1 lookup connection2
ip rule add fwmark 1 lookup connection1
ip rule add fwmark 2 lookup connection2
</pre>
<p>Add the iptables rules for SNAT:</p>
<pre>iptables -A POSTROUTING -o ppp0 -j SNAT --to-source 100.0.1.1
iptables -A POSTROUTING -o ppp1 -j SNAT --to-source 100.0.2.1
</pre>
<p>And finally add the rules for marking the connection they should be going out on. The first PREROUTING rule is for packets we forward to be returned via the interface they were received on. The OUTPUT rule is for packets handled on this PC to be returned on the correct interface too. We only want to mark new packets and restore marks on established connections else the packets</p>
<pre>-A PREROUTING          -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
-A OUTPUT              -m state --state ESTABLISHED,RELATED -j CONNMARK --restore-mark
-A PREROUTING -i ppp0  -m state --state NEW                 -j CONNMARK --set-mark 1
-A PREROUTING -i ppp1  -m state --state NEW                 -j CONNMARK --set-mark 2
-A PREROUTING -m connmark --mark 1                          -j MARK --set-mark 1
-A PREROUTING -m connmark --mark 2                          -j MARK --set-mark 2
-A PREROUTING -m state --state NEW -m connmark ! --mark 0   -j CONNMARK --save-mark
</pre>
<h2>Selective routing:</h2>
<p>To send all outgoing traffic on a specific table:</p>
<pre>-A PREROUTING -i eth0 -m state --state NEW -p tcp --dport  80 -j CONNMARK --set-mark 2
-A PREROUTING -i eth0 -m state --state NEW -p tcp --dport 443 -j CONNMARK --set-mark 2
</pre>
<p>&nbsp;</p>
<h2>References:</h2>
<p><a href="http://www.clintoneast.com/articles/multihomed.php">http://www.clintoneast.com/articles/multihomed.php</a></p>
<p><a href="http://linux-ip.net/html/adv-multi-internet.html">http://linux-ip.net/html/adv-multi-internet.html</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=160&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/11/28/multi-gateway-routing-with-iptables-and-iproute2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Ubuntu 9.10 impressions, extra packages.</title>
		<link>http://blog.khax.net/2009/11/05/ubuntu-9-10-impressions-extra-packages/</link>
		<comments>http://blog.khax.net/2009/11/05/ubuntu-9-10-impressions-extra-packages/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 00:00:45 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[9.10]]></category>
		<category><![CDATA[ubuntu-9.10]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=158</guid>
		<description><![CDATA[I updated my main laptop to Ubuntu 9.10 on it&#8217;s release. It called for a fresh install as this laptop get&#8217;s a lot of crap installed left right and centre and an upgrade was not going to clean it up. (Apache, Nginx and Lighttpd, tomcat, netbeans all installed and starting on bootup, argh, plus many [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=158&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I updated my main laptop to Ubuntu 9.10 on it&#8217;s release. It called for a fresh install as this laptop get&#8217;s a lot of crap installed left right and centre and an upgrade was not going to clean it up. (Apache, Nginx and Lighttpd, tomcat, netbeans all installed and starting on bootup, argh, plus many self compiled packages I installed without keeping track of.)</p>
<p>The only bugs I have been hit by was <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/446146">#446146</a>. A Huawei E169 USB here modem only shows up as a memory card reader. Quick install of one of the kernel packages listed fixed this for me though.</p>
<p>A PC that after upgrade was trying to detect the harddrives as part of fakeraid setup and would fail to boot. Booted with the previous kernel, removed dmraid, and rebooted and she&#8217;s all good.</p>
<p>And gscan2pdf needed three packages from Jaunty to save as PDF again:</p>
<ul>
<li>libmagickcore1_6.4.5.4.dfsg1-1ubuntu3.1_amd64.deb</li>
<li>libmagickwand1_6.4.5.4.dfsg1-1ubuntu3.1_amd64.deb</li>
<li>perlmagick_6.4.5.4.dfsg1-1ubuntu3.1_amd64.deb</li>
</ul>
<p>I am really impressed with the direction that to boot theming is taking, well done <a href="http://www.netsplit.com/2009/09/02/making-a-splash/">Scott</a> and team. Nvidia black redraw issues have gone away too. Sound is working better for me. Easier to select the speakers I want to output to. Havn&#8217;t tried Ubuntu One yet as most of my family is already using dropbox. Will probably try it for backing up some app data though.</p>
<p>The nvidia-settings tool would not save my settings for two monitor to xorg.conf as it could not parse it. So I instead just replaced the <strong>Screen Section</strong> in xorg.conf with the following and the extra monitor is auto detected and expanded to now:</p>
<pre>Section "Screen"
    Identifier    "Default Screen"
    DefaultDepth    24
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "DFP, CRT"
    Option         "metamodes" "DFP: nvidia-auto-select +0+0, CRT: nvidia-auto-select +1280+0"
     SubSection     "Display"
        Depth       24
    EndSubSection
EndSection</pre>
<p>I still have to work out how to slow down my mouse further with X as the slowest I can set it to in Gnome is still to fast at times.</p>
<p>And incase anybody like to compare notes, these are the packages I have installed/removed in the first couple of days (some from PPA&#8217;s, etc).</p>
<p><strong>Installed:</strong></p>
<p>cowbell<br />
bash-completion<br />
vim<br />
vim-gnome<br />
screen<br />
mc<br />
gwibber<br />
inkscape<br />
chromium<br />
virtualbox-3.0<br />
gvim<br />
fontypython<br />
nautilus-dropbox<br />
conky<br />
wine1.2<br />
cups-pdf<br />
gnome-do<br />
shutter<br />
libnss3-tools<br />
gstm<br />
gscan2pdf<br />
nmap<br />
thewidgetfactory<br />
agave</p>
<p><strong>Removed:</strong></p>
<p>latex-xft-fonts<br />
ttf-thai-tlwg<br />
ttf-kacst<br />
ttf-indic-fonts-core<br />
ttf-lao<br />
ttf-wqy-zenhei<br />
ttf-vlgothic<br />
ttf-unfonts-core<br />
f-spot</p>
<p>I removed the list of fonts to see 1) what would happen, 2) my default font list was cluttered &amp; 3) I can&#8217;t understand any of those languages anyway.</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=158&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/11/05/ubuntu-9-10-impressions-extra-packages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Liferay inroads</title>
		<link>http://blog.khax.net/2009/05/25/liferay-inroads/</link>
		<comments>http://blog.khax.net/2009/05/25/liferay-inroads/#comments</comments>
		<pubDate>Mon, 25 May 2009 13:29:12 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[Alfresco]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[liferay]]></category>
		<category><![CDATA[mmozine]]></category>
		<category><![CDATA[wintersky]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=139</guid>
		<description><![CDATA[After installing Alfresco and admittedly suffering a few hiccups with it I seem to be making enough progress that I also decided to investigate Liferay as an alternative to Plone as our intranet portal and internal information site. There are some areas that Plone really does well such as the content type handling and content [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=139&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After installing Alfresco and admittedly suffering a few hiccups with it I seem to be making enough progress that I also decided to investigate Liferay as an alternative to Plone as our intranet portal and internal information site.</p>
<p>There are some areas that Plone really does well such as the content type handling and content workflow. But lack of documentation in other areas has left me pulling my hair out at times, such as ldap user and group integration with openldap and active directory, debugging modules and some new gotcha each time something is updated in a buildout.</p>
<p>Liferay has also had a steep learning curve, but I found it no where as bad as Plone. No messing in the ZMI for setting up ldap auth, changing database backends or setting portal defaults. Just one config file. I have found the speed surprising compared to Plone on the same hardware too. With java webapps I have tried in the past I have been left with the impression of them being bloated, memory hungry and slow. But I am slowly coming around thanks to Alfresco and Liferay.<span id="more-139"></span></p>
<p>It took a long time to get the liferay-portal-5.2.2.war running in the ubuntu jaunty tomcat6 environment and it still had a couple of issues so I just went back to running the liferay-timcat6 bundle which does run well without issue. I guess that is the price I pay for avoiding java for so long.</p>
<p>To make it suitable for my needs the interface needed to be cleaned up and I decided to just create a fresh theme which can be seen in the screenshot below. The theme is called Winter Sky and is adapted from <a href="http://www.wpthemedesigner.com/2009/02/09/the-mmozine-theme/" target="_blank">MMOZINE</a>, and is available from the Liferay community plugin section.</p>
<p><a href="http://khax.files.wordpress.com/2009/05/screenshot.png"><img class="aligncenter size-medium wp-image-140" title="screenshot" src="http://khax.files.wordpress.com/2009/05/screenshot.png?w=300&#038;h=223" alt="screenshot" width="300" height="223" /></a></p>
<p>Other additions over the classic liferay theme are multiple level navigation menus and print styling css targets. Which were just a couple of extras that made things much more usable for my victims&#8230;. oh.. target users.</p>
<p>There are still a few visual glitches to fix, but everything seems usable and I will post the link to the Liferay project page once it is approved.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=139&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/05/25/liferay-inroads/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>

		<media:content url="http://khax.files.wordpress.com/2009/05/screenshot.png?w=300" medium="image">
			<media:title type="html">screenshot</media:title>
		</media:content>
	</item>
		<item>
		<title>Plone 3.2.2 on Jaunty with python sandbox</title>
		<link>http://blog.khax.net/2009/05/04/plone-322-on-jaunty-with-python-sandbox/</link>
		<comments>http://blog.khax.net/2009/05/04/plone-322-on-jaunty-with-python-sandbox/#comments</comments>
		<pubDate>Sun, 03 May 2009 14:55:40 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[easy_install]]></category>
		<category><![CDATA[jaunty]]></category>
		<category><![CDATA[PIL]]></category>
		<category><![CDATA[plone]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ubuntu-9.04]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=133</guid>
		<description><![CDATA[It seems that a lot of python2.4 support was dropped from Ubuntu 9.04 Jaunty. Support which without Plone would not run. I started recompiling python packages to bring back python2.4 builds, but this was turning into a slippery slope and would bring back problems if any python package was updated from Ubuntu again. Solution: Use [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=133&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It seems that a lot of python2.4 support was dropped from Ubuntu 9.04 Jaunty. Support which without Plone would not run. I started recompiling python packages to bring back python2.4 builds, but this was turning into a slippery slope and would bring back problems if any python package was updated from Ubuntu again.</p>
<h3>Solution:</h3>
<p>Use a separate user with it&#8217;s own install of python2.4 and any libraries needed for plone.</p>
<p>These are not complete instructions on how to get plone running again. But more or less just notes to point most people in the right path.<span id="more-133"></span></p>
<h3>Command history:</h3>
<pre>echo 'export PATH=$HOME/python/2.4/bin:$PATH' | tee -a ~/.bashrc
source ~/.bashrc
mkdir -p ~/python/2.4
mkdir python-build
cd python-build
wget http://python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c9.tar.gz http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz
sudo apt-get install build-essential zlib1g-dev libjpeg62-dev libfreetype6-dev
tar -xvf Python-2.4.6.tar.bz2
cd Python-2.4.6/
./configure --prefix=$HOME/python/2.4
make
make install
python -V
cd ..
tar -xvf setuptools-0.6c9.tar.gz
cd setuptools-0.6c9/
python setup.py build
python setup.py install
cd ..
tar -xvf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
python setup.py build
python setup.py install
python -c "import PIL"
sudo apt-get install libldap2-dev libsasl2-dev libssl-dev</pre>
<h3>Notes:</h3>
<p>Remove all old eggs.</p>
<p>Add the python install path to ~/.bashrc or the current shell.</p>
<p>install python, easy_install and PIL.</p>
<p>PIL needed to be install manually with `python setup.py install` as easy_install was not installing the PIL.pth files correctly.</p>
<p>Install python-ldap requirements if needed in plone are the last apt-get line.</p>
<p>Rerun bootstrap and buildouts in plone.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=133&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/05/04/plone-322-on-jaunty-with-python-sandbox/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenLDAP TLS with wildcard domain certs</title>
		<link>http://blog.khax.net/2009/04/03/openldap-tls-with-wildcard-domain-certs/</link>
		<comments>http://blog.khax.net/2009/04/03/openldap-tls-with-wildcard-domain-certs/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 12:10:16 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[certificates]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[openldap]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ubuntu-8.10]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=130</guid>
		<description><![CDATA[After the last post on the OpenLDAP trouble I had, I&#8217;ve continued trying new things with it and can confirm that wildcard domain certificates do succeed with OpenLDAP. When creating the certificate request enter for eg *.example.com in the common name field and you can then use the one certificate on all servers that fall [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=130&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After the last post on the OpenLDAP trouble I had, I&#8217;ve continued trying new things with it and can confirm that wildcard domain certificates do succeed with OpenLDAP.</p>
<p>When creating the certificate request enter for eg <em>*.example.com</em> in the <em>common name</em> field and you can then use the one certificate on all servers that fall in that domain.</p>
<p><strong>BIG WARNING!</strong> This is very dangerous if the keys are not secured properly. As if somebody compromises one key, they have compromised all of the services on all the machines that use the same key! So make sure you really want to do this, have the file permissions set correctly and are prepared for the consequences.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/130/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/130/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/130/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=130&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/04/03/openldap-tls-with-wildcard-domain-certs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Notes on ubuntu-8.10-serverguide-openldap</title>
		<link>http://blog.khax.net/2009/04/03/notes-on-ubuntu-810-serverguide-openldap/</link>
		<comments>http://blog.khax.net/2009/04/03/notes-on-ubuntu-810-serverguide-openldap/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 04:38:27 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[openldap]]></category>
		<category><![CDATA[pam]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[serverguide]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tls]]></category>
		<category><![CDATA[ubuntu-8.10]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=123</guid>
		<description><![CDATA[After deciding to learn to setup OpenLDAP yesterday I realised it was more than a days work, and that the documentation that I thought was going to be the most suited for my platform left a lot of holes for the beginner. I also had a firefox window with all the sites I used as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=123&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After deciding to learn to setup OpenLDAP yesterday I realised it was more than a days work, and that the documentation that I thought was going to be the most suited for my platform left a lot of holes for the beginner. I also had a firefox window with all the sites I used as a reference open in tabs, but then decided to print out some colouring pictures for the kids and one site kept crashing firefox (and ruined my day). So no citing references sorry, most of this information was only grepped from google eventually anyway.</p>
<p>The <a href="https://help.ubuntu.com/8.10/serverguide/C/openldap-server.html" target="_blank">openldap-server guide</a> does try to take you from wo to go fairly well and the following notes are just extra things that would have been handy to know or were needed to continue.<span id="more-123"></span></p>
<h2>Configuration</h2>
<p>The first ldapmodify commands are add extra DbIndex&#8217;s. These are handy to know when you receive errors in syslog such as:</p>
<ul>
<li>
<pre>Apr  3 11:01:18 virt01 slapd[11465]: &lt;= bdb_equality_candidates: (objectClass) not indexed</pre>
</li>
</ul>
<p>You can view the current DbIndex values:</p>
<ul>
<li>
<pre>~$ <strong>ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W olcDatabase={1}hdb olcDbIndex</strong>
Enter LDAP Password:
<strong>dn: olcDatabase={1}hdb,cn=config
olcDbIndex: objectClass eq
olcDbIndex: cn eq,pres,sub
olcDbIndex: uid eq,pres,sub
olcDbIndex: entryUUID eq
olcDbIndex: memberUid eq
olcDbIndex: uniqueMember eq</strong></pre>
</li>
</ul>
<p>And index&#8217;s can be added using the ldapmodify examples. If you need to delete the entire list and start again these ldapmodify commands will help you:</p>
<ul>
<li>
<pre><strong>dn: olcDatabase={1}hdb,cn=config
delete: olcDbIndex</strong></pre>
</li>
</ul>
<p>The sample of output from my ldap setup above will make an okay base to work with.</p>
<p>I followed the schemas section ok with the exception of a correction of the ldapadd command missing a &#8216;-W&#8217; arg (prompt for password).</p>
<ul>
<li>
<pre class="screen"><span class="command"><strong>ldapadd -x -D cn=admin,cn=config -W -f /tmp/ldif_output/cn\=config/cn\=schema/cn\=\{8\}misc.ldif</strong></span></pre>
</li>
</ul>
<h2>Populating LDAP</h2>
<p>You will now notice with the ldapadd command the reference a second admin principal (cn=admin,dc=example,dc=com). This principal is created with the same password as the first admin (cn=admin,cn=config).</p>
<h2 class="title">LDAP replication</h2>
<p>LDAP replication without TLS was setup within minutes following the guide.</p>
<p>Just be very careful to make sure all modifications are complete and correct before adding the ldif files.</p>
<p>The cn=config replication needs to be applied on both servers, but the dc=example,dc=com replication ldif only needs to be applied on one as once cn=config replication is setup it will replicate the dc=example,dc=com settings to the other server.</p>
<p>The second server also does not need to be setup with all the same changes as the first. Just setup the same domain and password when installing slapd then apply the replication ldif. The additional changes made on ldap01 will be replicated to ldap02 automatically. Once both servers have the ldif applied, then restart slapd on each.</p>
<p>It took a fair while to get replication working again using TLS. Most of my problems were certificate related and couple of missed changes in the TLS replication ldif that would not change back.</p>
<h2>TLS and SSL</h2>
<p>I created my certificates with CA.pl from an existing CA I have setup for other servers. When creating the certificates make sure that the commonName matches the host name of the server as it will be addressed. Ie:</p>
<ul>
<li>Server name: ldap01.example.com</li>
<li>commonName: ldap01.example.com</li>
</ul>
<p>TLS verification will fail if you do a ldap search against ldap://ldap01/ (as opposed to ldap://ldap01.example.com/).</p>
<p>I have not yet tested wildcard certificates either. Also the ca-certificate can be referred to either by file (olcTLSCACertificateFile) or the dir containing the cert (olcTLSCACertificatePath). But only referring to the cert by file name worked in my testing even though I added to cert to Ubuntu&#8217;s ca-certificate management scheme. Ie:</p>
<ul>
<li>
<pre><strong>sudo cp cacert.pem /usr/share/ca-certificates/Example.Com-CA.crt</strong></pre>
</li>
<li>
<pre><strong>echo 'Example.Com-CA.crt' | sudo tee -a /etc/ca-certificates.conf</strong></pre>
</li>
<li>
<pre><strong>sudo update-ca-certificates</strong></pre>
</li>
</ul>
<p>I had to set the SLAPD_SERVICES line to: SLAPD_SERVICES=&#8221;ldap:/// ldaps:/// ldapi:///&#8221; To allow TLS ldap:// connections from other hosts.</p>
<p>The TLS connections are over ldap:// and SSL is over ldaps://. TLS is the newer and preferred standard, but the ldap:// protocol also allows cleartext communication as a fallback.</p>
<p>To test a TLS connection use:</p>
<ul>
<li>
<pre><strong>ldapsearch -xLLL -b cn=config -D cn=admin,cn=config -W -H ldap://ldap01.example.com/ -ZZ</strong></pre>
</li>
</ul>
<ul>
<li><strong>-H ldap://ldap01.example.com/</strong> &#8211; specifies the hostname. Make sure it is the same as commonName in the certificate used.</li>
<li><strong>-ZZ</strong> &#8211; Issues a StartTLS command and requires it succed. Using just <strong>-Z</strong> issues StartTLS but still allows a cleartext connection if the StartTLS directive fails.</li>
</ul>
<p>To debug a connection append <strong>-d5</strong> to the command. It will spew a lot of output, but in there will most likely be the reason for the cause of the error.</p>
<p>The notes at the end of the TLS replication section are also handy for getting a TLS client connection working. I needed the following line in /etc/ldap/ldap.conf on all hosts:</p>
<ul>
<li>
<pre>TLS_CACERT /etc/ssl/certs/Example.Com-CA.crt</pre>
</li>
</ul>
<p>Or if you do not wish to check the validity of certificates then you could use:</p>
<ul>
<li>
<pre>TLS_REQCERT allow</pre>
</li>
</ul>
<h2>TLS Replication</h2>
<p>This should only be attempted once both hosts are confirmed working over TLS. Also make sure you test establishing a TLS connection from one host to the other (ie, running the ldapsearch from ldap01 using <strong>-ZZ -H ldap://ldap02.example.com/</strong>).</p>
<p>After adding the <em>cn=config</em> TLS change to one host (remember it will be replicated to the other host automatically), then restart both slapd backends (sudo /etc/init.d/slapd restart).</p>
<p>If that is working without any errors in syslog then proceed to the <em>dc=example,dc=com</em> tls replication and restart both backends again.</p>
<h2>LDAP Authentication</h2>
<p>My next headache was with the auth-client-config command. The correct command to use is:</p>
<ul>
<li>
<pre><strong>sudo auth-client-config -t nss -p lac_ldap</strong></pre>
</li>
</ul>
<p>Some sites also note another command that is actually unnecessary:</p>
<ul>
<li>
<pre><strong>sudo pam-auth-update ldap</strong></pre>
</li>
</ul>
<p>pam-auth-update allows you to pick which auth methods will be used in your system, but ldap is automatically added when you install libnss-ldap.</p>
<p>Other changes I made to /etc/ldap.conf was uncommenting two lines:</p>
<ul>
<li>
<pre>pam_filter objectclass=account</pre>
</li>
<li>
<pre>ssl start_tls</pre>
</li>
</ul>
<p>This requires a user have the objectclass=account attribute to be able to login. And the second requires a TLS connection to the ldap server.</p>
<p>To use TLS for pam auth you will need to make sure the cert is specified in /etc/ldap/ldap.conf just as on the server. This can be tested by running the same ldapsearch command on the client as on the server.</p>
<p>After managing to get that working on one client the rest were managed easily using puppet.</p>
<h2>User and Group Management</h2>
<p>The command to put the &#8216;secret&#8217; in /etc/ldapscripts/ldapscripts.passwd will not work as expected if you have a dollar symbol in the password. Ie:</p>
<ul>
<li>
<pre><strong>sudo sh -c "echo -n '$ecret' &gt; /etc/ldapscripts/ldapscripts.passwd"</strong></pre>
</li>
</ul>
<p>Will result in an empty passwd file. The correct way to echo the password is to escape the $. Ie: <strong>&#8216;\$ecret&#8217;</strong>. This is not a problem with the server guide, just an oversight that caught me out. It can be seen in the log file as:</p>
<ul>
<li>
<pre>&gt;&gt; 04/01/09 - 17:23 : Command : /usr/sbin/ldapadduser george example
ldap_bind: Server is unwilling to perform (53)
        additional info: unauthenticated bind (DN with no password) disallowed
ldap_bind: Server is unwilling to perform (53)
        additional info: unauthenticated bind (DN with no password) disallowed
Error adding user george to LDAP</pre>
</li>
</ul>
<p>The ldapscripts will also often fail if replication is not working either. Check the output of /var/log/ldapscripts.log.</p>
<ul>
<li>
<pre>&gt;&gt; 04/02/09 - 13:49 : Command : /usr/sbin/ldapadduser george example
Additional information: value does not conform to assertion syntax
ldap_modify: Server is unwilling to perform (53)
        additional info: shadow context; no update referral
Error adding user george to LDAP</pre>
</li>
</ul>
<p>That is the ldapscripts log output I get when replication was not working.</p>
<h2>Finale</h2>
<p>After that was all sorted out I was happy as Larry. Next thing to try is SASL authentication i guess. If anybody wants to point me in the right direction to assist with the Jaunty server guide it would be much appreciated. As well as any more notes and corrections to my post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=123&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/04/03/notes-on-ubuntu-810-serverguide-openldap/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>
	</item>
		<item>
		<title>Dlink DWA-110 + Ubuntu 8.10 = Happy Customer</title>
		<link>http://blog.khax.net/2009/03/20/dlink-dwa-110-ubuntu-810-happy-customer/</link>
		<comments>http://blog.khax.net/2009/03/20/dlink-dwa-110-ubuntu-810-happy-customer/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 22:17:15 +0000</pubDate>
		<dc:creator>agentk</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[dick smiths]]></category>
		<category><![CDATA[dlink]]></category>
		<category><![CDATA[drivers]]></category>
		<category><![CDATA[dse]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu-8.10]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://blog.khax.net/?p=119</guid>
		<description><![CDATA[Just a quick note for anybody looking to see if this Wireless (802.11b/g) USB adaptor works with linux before purchasing. I purchased one from Dick Smiths last night plugged it into my (Ubuntu-8.10 powered) laptop and was up and running within seconds. Signal strength and speed are fairly industry standard. Cost AU$50. I probably could [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=119&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a quick note for anybody looking to see if this Wireless (802.11b/g) USB adaptor works with linux before purchasing.</p>
<p>I purchased one from Dick Smiths last night plugged it into my (Ubuntu-8.10 powered) laptop and was up and running within seconds.</p>
<p>Signal strength and speed are fairly industry standard. Cost AU$50. I probably could have found it cheaper elseware but DSE was conveniently on my way home last night.</p>
<div id="attachment_120" class="wp-caption aligncenter" style="width: 180px"><a href="http://khax.files.wordpress.com/2009/03/dwa-110.jpg"><img class="size-full wp-image-120" title="dwa-110" src="http://khax.files.wordpress.com/2009/03/dwa-110.jpg?w=170&#038;h=136" alt="D-Link DWA-110" width="170" height="136" /></a><p class="wp-caption-text">D-Link DWA-110</p></div>
<p>Now just to find an access point with decent signal strength.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/khax.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/khax.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/khax.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/khax.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/khax.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/khax.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/khax.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/khax.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.khax.net&amp;blog=6484387&amp;post=119&amp;subd=khax&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.khax.net/2009/03/20/dlink-dwa-110-ubuntu-810-happy-customer/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">agentk</media:title>
		</media:content>

		<media:content url="http://khax.files.wordpress.com/2009/03/dwa-110.jpg" medium="image">
			<media:title type="html">dwa-110</media:title>
		</media:content>
	</item>
	</channel>
</rss>