<?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>Jon Lloyd &#187; Linux</title>
	<atom:link href="http://www.jonlloyd.co.uk/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jonlloyd.co.uk</link>
	<description>Ecommerce Professional</description>
	<lastBuildDate>Fri, 14 May 2010 14:24:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting up OpenVPN on Ubuntu</title>
		<link>http://www.jonlloyd.co.uk/setting-up-openvpn-on-ubuntu/</link>
		<comments>http://www.jonlloyd.co.uk/setting-up-openvpn-on-ubuntu/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 16:04:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jonlloyd.co.uk/?p=5</guid>
		<description><![CDATA[So here is the dilemma. I use a Mac and all of our office is Windows based.
I have a VPN connection set up between home and the office via the routers and the Watchguard Firebox firewall.
All is well until I go away from home. There is no client for the Watchguard Firebox firewall that will [...]]]></description>
			<content:encoded><![CDATA[<p>So here is the dilemma. I use a Mac and all of our office is Windows based.</p>
<p>I have a VPN connection set up between home and the office via the routers and the Watchguard Firebox firewall.</p>
<p>All is well until I go away from home. There is no client for the Watchguard Firebox firewall that will work on the Mac.</p>
<p>What I need is a way to connect to my home network when away from home with my Mac which will then in turn allow me to connect to my office.</p>
<p>There are probably many solutions out there so I am not saying this is the right or only solution out there for my dilemma</p>
<h2>Setting up the server</h2>
<p>My Server is running Ubuntu 9.04 in desktop mode with a fixed IP address of 192.168.1.9.</p>
<p>Install openvpn</p>
<p><code>sudo apt-get install openvpn</code></p>
<p>Comment all lines in /etc/default/openvpn with # and add:</p>
<p><code>AUTOSTART="openvpn"</code></p>
<p>This line tells OpenVPN which configuration file it should use by default when starting. Configuration files are in /etc/openvpn and use the .conf extension so the setting above points to/etc/openvpn/openvpn.conf, a file that still does not exist and we will create later</p>
<p>The following will start, stop or restart OpenVPN as usual, let&#8217;s see:</p>
<p>Start OpenVPN:<br />
<code>/etc/init.d/openvpn start</code></p>
<p>Stop OpenVPN:<br />
<code>/etc/init.d/openvpn stop</code></p>
<p>Restart OpenVPN:<br />
<code>/etc/init.d/openvpn restart</code></p>
<p>Every time you change settings in /etc/openvpn/openvpn.conf you will need to restart OpenVPN.</p>
<h2>Keys and certificates</h2>
<p>Now we need to create security certificates and keys. We&#8217;ll do all this in the server as root:</p>
<p><code>sudo su</code></p>
<p>And add your password to get root access</p>
<p><code>cd /etc/openvpn/</code></p>
<p>Copy the directory easy-rsa to /etc/openvpn:</p>
<p><code>cp -r /usr/share/doc/openvpn/examples/easy-rsa/ .</code></p>
<p>Remember we&#8217;re still inside the /etc/openvpn directory. Now let&#8217;s edit the file vars with our favorite editor (replace vi with yours):</p>
<p><code>nano easy-rsa/2.0/vars</code></p>
<p>modify the below</p>
<p><code>export KEY_COUNTRY="UK"<br />
export KEY_PROVINCE="SU"<br />
export KEY_CITY="Birmingham"<br />
export KEY_ORG="home"<br />
export KEY_EMAIL="jon@example.com"</code></p>
<p>Save and quit.</p>
<p>Now run:</p>
<p><code>cd  easy-rsa/2.0/<br />
. ./vars</code></p>
<p>Important: that&#8217;s a period, a space and another period followed by /vars. This is a common confusion in many setups.</p>
<p>Now:</p>
<p><code>./clean-all</code></p>
<p>The next command creates your certificate authority (CA) using the parameters you just set, you should just add Common Name, I used OpenVPN-CA. For this step you&#8217;ll need OpenSSL; if you don&#8217;t have it in your server install it by running:</p>
<p><code>sudo apt-get install openssl</code></p>
<p>Ok, now we&#8217;re ready:</p>
<p><code>./build-ca</code></p>
<p>Now let&#8217;s create the keys, first the server:</p>
<p><code>./build-key-server server</code></p>
<p>This is important. When build-key-server asks for Common Name write server, the same parameter you provided to the command.</p>
<p>Also you&#8217;ll need to answer yes to these two questions: Sign the certificate? [y/n] and 1 out of 1 certificate requests certified, commit? [y/n].</p>
<p>Now the key for the client:</p>
<p><code>./build-key client1</code></p>
<p>Use client1 as Common Name, the same parameter you used above for build-key.<br />
You can repeat this step if you want to have more clients, just replace the parameter with client2,client3, etc.<br />
Now let&#8217;s create Diffie Hellman parameters:</p>
<p><code>./build-dh</code></p>
<p>There you are! Now you should have a new directory with your certificates and keys:/etc/openvpn/easy-rsa/keys. To configure your first client copy these files from servo to cliento:</p>
<p>ca.crt<br />
client1.crt<br />
client1.key</p>
<p>Ideally you should use a secure channel, I use scp with RSA authentication</p>
<h2>Openvpn.conf for the server:</h2>
<p><code>dev tun<br />
proto tcp<br />
port 1194<br />
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt<br />
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt<br />
key /etc/openvpn/easy-rsa/2.0/keys/server.key<br />
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem<br />
user nobody<br />
group nogroup<br />
server 10.8.77.0 255.255.255.0<br />
persist-key<br />
persist-tun<br />
#status openvpn-status.log<br />
#verb 3<br />
client-to-client</code></p>
<p>Place this file in /etc/openvpn/</p>
<p>Now start openvpn by</p>
<p><code>/etc/init.d/openvpn start</code></p>
<h2>Setting up the router</h2>
<p>Just make sure that the port and protocol 1194 TCp in my case are forwarded to the server 192.168.1.9</p>
<h2>Setting up tunnelblick</h2>
<p>Download the dmg from <a href="http://code.google.com/p/tunnelblick/">http://code.google.com/p/tunnelblick/</a></p>
<p>Install as usual by dragging the icon to the applications folder.</p>
<p>When you run it for the first time it will add a black tunnel icon near your spotlight icon.</p>
<p>You will also need to enter your admin password as the client requires root access.</p>
<p>When clicking the tunnel you are presented with options. The defaults are fine.</p>
<p>Click on the details and you will see the OpenVPN log output.</p>
<p>Click the edit configuration</p>
<h2>Openvpn.conf  client content:</h2>
<p><code>dev tun<br />
client<br />
proto tcp<br />
remote 81.174.97.97 1194<br />
resolv-retry infinite<br />
nobind<br />
user nobody<br />
group nogroup<br />
# Try to preserve some state across restarts.<br />
persist-key<br />
persist-tun<br />
ca ca.crt<br />
cert client1.crt<br />
key client1.key<br />
comp-lzo<br />
# Set log file verbosity.<br />
verb 3</code></p>
<p>Paste your client openvpn.conf copy in to the text editor and save.</p>
<p>Don’t worry it will overwrite despite the prompt.</p>
<p>It saves the file in  user/Library/Application Support/Tunnelblick/Configurations</p>
<p>I placed the certificate and keys for the client in here as well. You can place them anywhere but you would need to change the client openvpn.conf accordingly.</p>
<p>Now press connect and you should see the verbose output suggesting a good connection</p>
<h2>Test</h2>
<p>If you ifconfig on the mac you should get an extra entry for tun0</p>
<p>Now ping 10.8.77.1 and you should get a reply from the server.</p>
<p>I can now vnc to this server and then vnc to from the server to any office computer on the subnet 192.168.40.0</p>
<p>Other things to consider could be username password authentication as well as the certificates in case the Mac is stolen.</p>
<p>I would now like to route traffic so that I can get to the 192.168.40.0 subnet without having to vnc to the openvpn server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonlloyd.co.uk/setting-up-openvpn-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
