<?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>Rob Garth &#187; openvpn</title>
	<atom:link href="http://blog.sumostyle.net/robg/tag/openvpn/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sumostyle.net/robg</link>
	<description>Mildly Useful Stuff</description>
	<lastBuildDate>Fri, 12 Aug 2011 00:36:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>OpenVPN client with Username and Password auth</title>
		<link>http://blog.sumostyle.net/robg/2010/03/01/ovpn-client/</link>
		<comments>http://blog.sumostyle.net/robg/2010/03/01/ovpn-client/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 01:46:20 +0000</pubDate>
		<dc:creator>robg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.sumostyle.net/robg/?p=467</guid>
		<description><![CDATA[Following on from last week&#8217;s post. We now need to setup the client. Network Manager The easiest openvpn client is network-manager. If you are using Ubuntu run: # aptitude install network-manager-openvpn # restart network-manager Now click on the network-manager applet, select configure VPN, and setup a new open-vpn connection. Set the gateway to you server [...]]]></description>
			<content:encoded><![CDATA[<p>Following on from last week&#8217;s <a href="http://blog.sumostyle.net/robg/2010/02/25/ovpn-server/">post</a>. We now need to setup the client.<br />
<span id="more-467"></span></p>
<h4>Network Manager</h4>
<p>The easiest openvpn client is network-manager. If you are using Ubuntu run:</p>
<p><code># aptitude install network-manager-openvpn<br />
# restart network-manager</code></p>
<ul>
<li>Now click on the network-manager applet, select configure VPN, and setup a new open-vpn connection.</li>
<li>Set the gateway to you server</li>
<li>Set the type to Password</li>
<li>Point your CA to a copy of your server&#8217;s ca.crt and everything should just work</li>
</ul>
<h4>Everything Else</h4>
<p>Linux, Windows and OSX all have ports of OpenVPN, and I have setup the client on each of them. Unless you want to pay for Viscosity on the mac, the chances are you will need a client configuration file.</p>
<p>Attached is a simple client configuration file that will work. Edit it to match your server&#8217;s settings where appropriate. You will need this and your ca.crt in the same directory. On Windows the file extenion is &#8220;.ovpn&#8221;. On linux my file is called <code>/etc/openvpn/client.conf</code></p>
<pre>
##############################################
# Sample client-side OpenVPN 2.0 config file.
# for connecting to multi-client server.
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

dev tun
proto udp

# The hostname/IP and port of the server.
remote my-server-2.domain 1194

# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Try to preserve some state across restarts.
persist-key
persist-tun

# Certificate Authority
ca ca.crt

# Username/Password authentication is used on the server
auth-user-pass

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
ns-cert-type server

# Set log file verbosity.
verb 3
</pre>
<p>On linux to start the openvpn client simply type:<br />
<code># openvpn -config /etc/openvpn/client.conf</code></p>
<p>To manage the connection on Windows I would suggest using <a href="http://openvpn.se/">OpenVPN GUI</a>. And either <a href="http://www.tunnelblick.net/">tunnelblick</a>, or <a href="http://www.viscosityvpn.com/">Viscosity</a> (non-free) on OSX.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumostyle.net/robg/2010/03/01/ovpn-client/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>OpenVPN server with Username and Password auth</title>
		<link>http://blog.sumostyle.net/robg/2010/02/25/ovpn-server/</link>
		<comments>http://blog.sumostyle.net/robg/2010/02/25/ovpn-server/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 10:45:16 +0000</pubDate>
		<dc:creator>robg</dc:creator>
				<category><![CDATA[Uncategorized]]></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://blog.sumostyle.net/robg/?p=442</guid>
		<description><![CDATA[I did this on Debian but these instruction should work equally well for Ubuntu Setup IP Forwarding/Masquerading/Firewall To turn on IP Forwarding: # echo 1 &#62; /proc/sys/net/ipv4/ip_forward Set the change permanantly in /etc/sysctl.conf by uncommenting the line: net.ipv4.ip_forward=1 To turn on IP Masquerading add the following IP Tables rule: # iptables --table nat --append POSTROUTING [...]]]></description>
			<content:encoded><![CDATA[<p>I did this on Debian but these instruction should work equally well for Ubuntu<br />
<span id="more-442"></span></p>
<h4>Setup IP Forwarding/Masquerading/Firewall</h4>
<p><strong>To turn on IP Forwarding:</strong><br />
<code># echo 1 &gt; /proc/sys/net/ipv4/ip_forward</code></p>
<p>Set the change permanantly in /etc/sysctl.conf by uncommenting the line:<br />
<code>net.ipv4.ip_forward=1</code></p>
<p><strong>To turn on IP Masquerading add the following IP Tables rule:</strong></p>
<p><code># iptables --table nat --append POSTROUTING \<br />
--out-interface eth0 --jump MASQUERADE</code></p>
<p><strong>Firewall</strong><br />
If you are running a firewall, and I strongly recommend you do on a public facing box you need to allow UDP on port 1194 into you box.<br />
<code># iptables -A INPUT -udp -m udp --dport 1194 -j ACCEPT</code></p>
<p>But these rules need be persistant so we need to create a script to run when the interface starts up</p>
<p><code># iptables-save &gt; /etc/iptables.conf</code></p>
<p>Create a new file: /etc/network/if-up.d/iptables and paste in the following:</p>
<p><code>#!/bin/sh<br />
/sbin/iptables-restore &lt; /etc/iptables.conf</code></p>
<p>Set it to executable:<br />
<code># chmod 755 /etc/network/if-up.d/iptables</code></p>
<p>Now when networking starts the firewall is brought up. If all you have done is what is above, your box is not really firewalled, as no traffic is dropped or blocked. For a basic firewall the following config, forwards everything, allows bind internally and only allows SSH and OpenVPN on the external interface.</p>
<p>/etc/iptables.conf (example):</p>
<pre>#
*nat
&#58;PREROUTING ACCEPT [36:18250]
&#58;POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [12:806]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
#
*filter
:INPUT ACCEPT [19:1037]
:FORWARD ACCEPT [420:191307]
:OUTPUT ACCEPT [314:39042]
# Allow everything on loopback
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
# Allow already established connections
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# Allow SSH
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT
# Allow DNS to this machine fron the private network
# (If you plan to run you own DNS, I run dns_masq)
-A INPUT -p tcp --dport 53 -s 10.8.0.0/16 -j ACCEPT
# Allow OpenVPN
-A INPUT -p udp -m udp --dport 1194 -j ACCEPT
# DROP the rest
-A INPUT -i eth0 -j DROP
COMMIT
#</pre>
<h4>Setup Open VPN</h4>
<p><strong>Installation</strong></p>
<p>Install OpenVPN:</p>
<p><code># aptitude install openvpn openssl<br />
</code></p>
<p>Edit /etc/default/openvpn. Comment all lines, and add:</p>
<p><code>AUTOSTART="openvpn"</code></p>
<p><strong>Create Certificates and Keys</strong></p>
<p>On you server as root:</p>
<p><code># cd /etc/openvpn</code></p>
<p>Copy the the following directory</p>
<p><code># cp -r /usr/share/doc/openvpn/examples/easy-rsa .<br />
# cd easy-rsa/2.0/</code></p>
<p>Edit the file &#8220;vars&#8221;. Change the default values at the bottom of the file to match your details.</p>
<p>Import you ssl settings:<br />
<code># . ./vars</code></p>
<p>run: <code># ./cleann-all</code>. Do not run this every time as it will remove all existing certificates.</p>
<p>Create your Certificate Authority</p>
<p><code># ./build-ca</code></p>
<p>Give it a sensible common-name, something like: &#8220;OpenVPN CA&#8221;</p>
<p>Now build the key and certificate for you server</p>
<p><code># ./build-key-server server</code></p>
<p>Set the common name to &#8220;server&#8221;</p>
<p>Answer yes to signing the certificate and commiting it.</p>
<p>Now let&#8217;s create Diffie Hellman parameters:</p>
<p><code># ./build-dh</code></p>
<p>Most other guides now get you to generate client certs, but we are using  username and password authentication so we do not need to do this.</p>
<p><strong>Configure OpenVPN</strong></p>
<p>Edit the file /etc/openvpn/openvpn.conf and add the following (the comments are unnecessary they are just there for explanation):</p>
<pre>
    dev tun
    ## udp is recommended, avoid TCP over TCP
    proto udp
    ## any port will do, this is the standard
    port 1194 

    ## certs we created earlier
    ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
    cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
    key /etc/openvpn/easy-rsa/2.0/keys/server.key
    dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem

    user nobody
    group nogroup
    ## You can make this any private subnet you like
    server 10.8.0.0 255.255.255.0

    persist-key
    persist-tun

    #status openvpn-status.log
    #verb 3
    client-to-client

    ## make this connection the default gateway for network traffic
    push "redirect-gateway def1"
    ## I am running dns_masq, you may want to put your server's DNS here
    ## or even google: 8.8.8.8
    push "dhcp-option DNS 10.8.0.1"

    log-append /var/log/openvpn

    ## User authentication settings. Usernames must be able to authenticate with PAM
    ## To use radius or another auth mechanism create /etc/pam.d/openvpn
    ## by default it is doing common-auth (a user must have a local accout and pasword)
    plugin /usr/lib/openvpn/openvpn-auth-pam.so login
    client-cert-not-required
    username-as-common-name

    ## A management interface allows you to telnet from local host to use
    ## telnet localhost 7505
    management localhost 7505
</pre>
<p>Restart OpenVPN: <code># /etc/init.d/openvpn restart</code></p>
<p>So this is the server done. We haven&#8217;t configured anything to connect to it yet.<br />
Client how-to comming up next time.</p>
<p><strong>Update.</strong> <em>Client how-to is <a href="http://blog.sumostyle.net/robg/2010/03/01/ovpn-client/">available</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumostyle.net/robg/2010/02/25/ovpn-server/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>OpenVPN</title>
		<link>http://blog.sumostyle.net/robg/2010/02/25/openvpn/</link>
		<comments>http://blog.sumostyle.net/robg/2010/02/25/openvpn/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 10:14:31 +0000</pubDate>
		<dc:creator>robg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[debian. linux]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://blog.sumostyle.net/robg/2010/02/25/openvpn/</guid>
		<description><![CDATA[I just replaced my potop install with openvpn. It is relatively easy to set up, and once working it is more secure, and much. much faster. From my completely unscientific, anecdotal observations, about 3 times faster. I will get around to writing a full howto in the next week or so.]]></description>
			<content:encoded><![CDATA[<p>I just replaced my  potop install with openvpn. It is relatively easy to set up, and once working it is more secure, and much. much faster. From my completely unscientific, anecdotal observations, about 3 times faster.</p>
<p>I will get around to writing a full howto in the next week or so.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumostyle.net/robg/2010/02/25/openvpn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

