<?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>My two ¢&#039;s &#187; OpenVPN</title>
	<atom:link href="http://www.linuxaddicted.de/blog/tag/openvpn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linuxaddicted.de/blog</link>
	<description>A Gentoo addict, linux admin and developer</description>
	<lastBuildDate>Wed, 31 Mar 2010 12:12:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>OpenVPN active/active cluster</title>
		<link>http://www.linuxaddicted.de/blog/2010/02/01/openvpn-activeactive-cluster/</link>
		<comments>http://www.linuxaddicted.de/blog/2010/02/01/openvpn-activeactive-cluster/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 18:49:10 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[keepalived]]></category>
		<category><![CDATA[OpenVPN]]></category>

		<guid isPermaLink="false">http://www.linuxaddicted.de/blog/?p=293</guid>
		<description><![CDATA[<p>Code snippets are for Gentoo systems but it should be easy to adapt this for other systems</p> <p>This is a small howto explaining how to run a active/active Cluster (keeplaived) setup with OpenVPN. The active/active reflects that both cluster nodes run the same OpenVPN instance. In server mode this setup leads to routing problems <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.linuxaddicted.de/blog/2010/02/01/openvpn-activeactive-cluster/">OpenVPN active/active cluster</a></span>]]></description>
			<content:encoded><![CDATA[<p><em>Code snippets are for Gentoo systems but it should be easy to adapt this for other systems</em></p>
<p>This is a small howto explaining how to run a active/active Cluster (keeplaived) setup with OpenVPN. The active/active reflects that both cluster nodes run the same OpenVPN instance. In server mode this setup leads to routing problems as both nodes have the tunnel route added during startup (not after connect). This results in routing trouble as i needed the passive node to access the VPN tunnel via the active node. This is how i solved it:<br />
<span id="more-293"></span></p>
<h2>Routing setup</h2>
<p>Both firewall nodes have a static route which forwards tunnel traffic to one of the internal cluster IP&#8217;s. The metric for this route is 2 so a active tunnel is preferred over that static route.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">routes_eth2</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #ff0000;">&quot;192.168.44.0/24 via 192.168.20.254 metric 2&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>It doesn&#8217;t matter which node is active and gets the VPN connects as the other node has the right routing entries.</p>
<h2>OpenVPN configuration</h2>
<p>This setup requires the use of sudo or to run the OpenVPN daemon as root (sudo, sudo, sudo!!!). First we disable to automatically adding of routes and specify scripts for client-connect and client-disconnect. Dont forget to set script security.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">route-noexec
client-connect <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>cluster_routing.sh
client-disconnect <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>openvpn<span style="color: #000000; font-weight: bold;">/</span>cluster_routing.sh
script-security <span style="color: #000000;">3</span></pre></div></div>

<h2>cluster_routing.sh</h2>
<p>This is a simple version of the script but it should be sufficient to work in most scenarios.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## This is useful for debugging and to get the available env vars</span>
<span style="color: #666666; font-style: italic;">##exec &amp;gt; /tmp/ovpn.debug.$$ 2&amp;gt;&amp;amp;1; set -x</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${script_type}</span>&quot;</span> == <span style="color: #ff0000;">&quot;client-connect&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>route add <span style="color: #660033;">-net</span> <span style="color: #800000;">${route_network_1}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> gw <span style="color: #800000;">${route_vpn_gateway}</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>route del <span style="color: #660033;">-net</span> <span style="color: #800000;">${route_network_1}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> gw <span style="color: #800000;">${route_vpn_gateway}</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>This script adds and removes the needed route to get a operational tunnel.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxaddicted.de/blog/2010/02/01/openvpn-activeactive-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

