<?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>A Million Monkeys &#187; openvpn</title>
	<atom:link href="http://www.monkeedev.co.uk/blog/tag/openvpn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.monkeedev.co.uk/blog</link>
	<description>Surviving life as a sysadmin.</description>
	<lastBuildDate>Tue, 22 Jun 2010 15:48:58 +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>Setting up OpenVPN in debian/ubuntu</title>
		<link>http://www.monkeedev.co.uk/blog/2009/03/06/setting-up-openvpn-in-debianubuntu/</link>
		<comments>http://www.monkeedev.co.uk/blog/2009/03/06/setting-up-openvpn-in-debianubuntu/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 09:18:01 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://www.monkeedev.co.uk/blog/?p=22</guid>
		<description><![CDATA[This is little bit later than I originally intended but I finally got around to setting up OpenVPN, and here&#8217;s how I did it. This guide is pretty simple to follow and should have an OpenVPN server on debian or ubuntu working within half an hour. I&#8217;ll also explain how to connect to the VPN [...]]]></description>
			<content:encoded><![CDATA[<p>This is little bit later than I originally intended but I finally got around to setting up OpenVPN, and here&#8217;s how I did it.</p>
<p>This guide is pretty simple to follow and should have an OpenVPN server on debian or ubuntu working within half an hour. I&#8217;ll also explain how to connect to the VPN from a windows PC.</p>
<p>First, install OpenVPN on the server (you&#8217;ll need to be root for all of this guide)</p>
<blockquote><p>apt-get install openvpn</p></blockquote>
<p>Next, we need to configure the server. You need to make a decision here whether you want tun (routed) or tap (bridged) connections. The main difference is that tap will give the client a network address on the server network, whereas tun creates a private network managed by the server. In this guide I will use tap because I find that it works better with windows clients.</p>
<p>Now you need to create certificates for the server and client for authentication purposes (which is much more secure than the passwords used in pptp). This is done through a number of steps:</p>
<p>Preparing to generate the keys</p>
<blockquote><p>mkdir /etc/openvpn/easy-rsa<br />
cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa</p></blockquote>
<p>Now you need to edit /etc/openvpn/easy-rsa/vars with your required settings. You only really need to change the last section which is the default values for the fields in the certificates.</p>
<p>Generate the certificate authority (CA) which will be used to sign the server and client certificates.</p>
<blockquote><p>cd /etc/openvpn/easy-rsa<br />
source ./vars<br />
./clean-all<br />
./build-ca</p></blockquote>
<p>Next, we need to create the server keys</p>
<blockquote><p>./build-key-server servername</p></blockquote>
<p>Answer &#8216;yes&#8217; when asked to sign the certificate and commit to the database, and then you&#8217;ll need to generate the diffie-hellman parameters which are used for key exchange between the client and server.</p>
<blockquote><p>./build-dh</p></blockquote>
<p>And finally, create some client keys which will be used to allow clients to authenticate with the server. I prefer to use pkcs12 which stores the client public key and certificate in one passworded file.</p>
<blockquote><p>./build-key-pkcs12 client1</p></blockquote>
<p>As before, sign the key and commit to the database. You will be asked for a password which the client will use to connect to the server.</p>
<p>Now all the keys are created, we need to configure the server.</p>
<blockquote><p>vim /etc/openvpn/server.conf<br />
(add the following lines)<br />
port 443<br />
proto tcp<br />
dev tap<br />
ca /etc/openvpn/easy-rsa/keys/ca.crt<br />
cert /etc/openvpn/easy-rsa/keys/servername.crt<br />
key /etc/openvpn/easy-rsa/keys/servername.key<br />
dh /etc/openvpn/easy-rsa/keys/dh1024.pem<br />
ifconfig-pool-persist ipp.txt<br />
server-bridge 10.1.0.1 255.255.255.0 10.1.0.236 10.1.0.245<br />
push &#8220;route 10.0.0.0 255.0.0.0&#8243;<br />
keepalive 10 120<br />
comp-lzo<br />
persist-key<br />
persist-tun<br />
status /var/log/openvpn-status.log<br />
verb 3</p></blockquote>
<p>The only lines which you will need to change are &#8216;server-bridge&#8217;, which is simply the default gateway, subnet mask, and the start and end IP&#8217;s to assign the clients, and the push route, which pushes specific routes to all clients.</p>
<p>Now we need to create an ethernet bridge. First, we need to install bridge-utils:</p>
<blockquote><p>apt-get install bridge-utils</p></blockquote>
<p>Rather than explain how to set up a network bridge, I found a shell script which will do it for you. This can be found <a title="Ethernet Bridge" href="http://www.monkeedev.co.uk/blog/wp-content/uploads/2009/openvpn/bridge.txt">here</a>. Just edit this with your network settings and execute it. You will also need to set it to create the bridge at boot time:</p>
<blockquote><p>update-rc.d bridge defaults</p></blockquote>
<p>Now you can start the openvpn server</p>
<blockquote><p>/etc/init.d/openvpn start</p></blockquote>
<p>Now we need to set up the windows client. First, download the OpenVPN client from <a href="http://openvpn.net/index.php/downloads.html">here</a> (at the time of writing, select 2.1 RC15). Install it, and create a file &#8216;client.conf&#8217; in the config directory with the following parameters</p>
<blockquote><p>client<br />
dev tap<br />
proto tcp<br />
remote x.x.x.x 443 # (replace with your server IP)<br />
resolv-retry infinite<br />
nobind<br />
pkcs12 client1.p12 # (replace with the client name)<br />
ns-cert-type server<br />
comp-lzo<br />
verb 3</p></blockquote>
<p>You can also add &#8216;redirect-gateway&#8217; to the client configuration to pass all traffic down the VPN tunnel (rather than just traffic intended for the VPN itself).</p>
<p>Now copy the client1.p12 certificate file to the config directory on the client, start the gui, and connect. Everything should now work.</p>
<p>If you need to create any clients in the future, do the following:</p>
<blockquote><p>cd /etc/openvpn/easy-rsa<br />
source ./vars<br />
./build-key-pkcs12 clientx</p></blockquote>
<p>If one of your certificates is compromised, you can revoke it using the guide <a href="http://openvpn.net/index.php/documentation/howto.html#revoke">here</a>.</p>
<p>This guide has been written from my notes and what I remember, so there may be a couple of things which aren&#8217;t 100% right. If anything goes wrong then post a comment or contact me and I&#8217;ll update the guide.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F&amp;title=Setting+up+OpenVPN+in+debian%2Fubuntu" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F&amp;title=Setting+up+OpenVPN+in+debian%2Fubuntu" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F&amp;title=Setting+up+OpenVPN+in+debian%2Fubuntu" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F&amp;title=Setting+up+OpenVPN+in+debian%2Fubuntu" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F&amp;title=Setting+up+OpenVPN+in+debian%2Fubuntu" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Setting+up+OpenVPN+in+debian%2Fubuntu+@+http%3A%2F%2Fwww.monkeedev.co.uk%2Fblog%2F2009%2F03%2F06%2Fsetting-up-openvpn-in-debianubuntu%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.monkeedev.co.uk/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.monkeedev.co.uk/blog/2009/03/06/setting-up-openvpn-in-debianubuntu/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
