<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>Topdog.za.net</title>
    <link>http://www.topdog.za.net</link>
    <description>A bored sysadmin</description>
    <pubDate>Fri, 26 Feb 2016 10:06:56 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Commandline OpenVPN client on Mac OSX with macports</title>
      <link>http://www.topdog.za.net/2013/01/31/commandline-openvpn-client-on-mac-osx-with-macports</link>
      <pubDate>Thu, 31 Jan 2013 07:40:00 SAST</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Mac OS X]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[Unix]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2013/01/31/commandline-openvpn-client-on-mac-osx-with-macports</guid>
      <description>Commandline OpenVPN client on Mac OSX with macports</description>
      <content:encoded><![CDATA[<p>Most people use TunnelBrick to setup OpenVPN client connections on Mac OSX,
i prefer using the command line.</p>
<p>To get OpenVPN up and running off the command line is a simple process. The
commands below need to be run as a privileged user if your root account is
not enabled use sudo to run the commands.</p>
<h2>Install OpenVPN</h2>
<p>To install OpenVPN 2 from macports run:</p>
<pre><code>port install openvpn2
</code></pre>
<h2>Install TunTap</h2>
<p>To install <a href="http://tuntaposx.sourceforge.net/">TunTap</a> from macports run:</p>
<pre><code>port install tuntaposx
</code></pre>
<p>Configure it to startup at boot:</p>
<pre><code>launchctl load -w /Library/LaunchDaemons/org.macports.tuntaposx.plist
</code></pre>
<p>You need <a href="http://tuntaposx.sourceforge.net/">TunTap</a> as it allows you
to create virtual interfaces using the supplied kernel extensions.
If you don't install TunTap you will get the error
<em>Cannot allocate TUN/TAP dev dynamically</em> when you try and make a
OpenVPN connection.</p>
<h2>Configuration</h2>
<p>Create a directory to hold your configuration and keys.</p>
<pre><code>mkdir /opt/local/etc/openvpn
</code></pre>
<p>Place your keys and configuration files in /opt/local/etc/openvpn/</p>
<p>A sample client configuration is provided below.</p>
<div class="pygments_murphy"><pre>client
dev tun
proto udp
remote vpn.home.topdog-software.com 1194
nobind
resolv-retry infinite
tls-client
ca /opt/local/etc/openvpn/ca.crt
cert /opt/local/etc/openvpn/client.crt
key /opt/local/etc/openvpn/client.key
ns-cert-type server
cipher BF-CBC
tls-cipher DHE-RSA-AES256-SHA
tls-remote vpn.home.topdog-software.com
tls-auth /opt/local/etc/openvpn/tls-auth.key 1
remote-cert-tls server
comp-lzo
persist-key
persist-tun
mute-replay-warnings
verb 3
mlock
</pre></div>

<h2>Connecting</h2>
<p>To connect simply run:</p>
<pre><code>openvpn2 --config /opt/local/etc/openvpn/openvpn.conf
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>IOS 6 Breaks Certificate based IPSEC VPNs</title>
      <link>http://www.topdog.za.net/2012/09/29/ios-6-breaks-certificate-based-ipsec-vpns</link>
      <pubDate>Sat, 29 Sep 2012 11:30:00 SAST</pubDate>
      <category><![CDATA[Mac OS X]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[IPSEC]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/09/29/ios-6-breaks-certificate-based-ipsec-vpns</guid>
      <description>IOS 6 Breaks Certificate based IPSEC VPNs</description>
      <content:encoded><![CDATA[<p>I have found that the recent release of IOS 6 breaks Certificate based IPSEC VPN functionality.
IPSEC VPNs using preshared keys still do work however.</p>
<p>A number of other users <a href="https://discussions.apple.com/thread/4312913?start=0&amp;tstart=0">report</a> the having the same issue, if IPSEC VPN functionality
is critical for you i would advise you don't upgrade until a fix
is released.</p>]]></content:encoded>
    </item>
    <item>
      <title>Mac OSX IPSEC VPN via command line using builtin Racoon client</title>
      <link>http://www.topdog.za.net/2012/09/19/mac-osx-ipsec-vpn-via-command-line-using-builtin-racoon-client</link>
      <pubDate>Wed, 19 Sep 2012 07:30:00 SAST</pubDate>
      <category><![CDATA[Mac OS X]]></category>
      <category><![CDATA[Howto]]></category>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Linux]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[IPSEC]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/09/19/mac-osx-ipsec-vpn-via-command-line-using-builtin-racoon-client</guid>
      <description>Mac OSX IPSEC VPN via command line using builtin Racoon client</description>
      <content:encoded><![CDATA[<h2>Introduction</h2>
<p>The Mac OSX IPSEC VPN client setup via "System preferences" only supports
IPSEC/XAUTH and IPSEC/L2TP both of which give you a different IP address for
your tunnel interface. System preferences on the backend uses Racoon
so it is possible via the command line to setup a pure IPSEC connection.</p>
<p>In my <a href="http://bit.ly/WABVAZ">previous post</a> i described how to configure a Strongswan server for
use with Mac OSX, Ipad, Iphone clients. For the sake of brevity i will not
repeat that in this post.</p>
<p>This scenario assumes you are connected to a lan 10.128.1.0/24 and your
IP address is 10.128.1.2 and you are connecting to a remote network 
192.168.1.0/24 protected by an IPSEC VPN running Strongswan on a gateway with
a dynamic address being resolved via dynamic DNS.
IPSEC Authentication is done using Certificates.</p>
<h2>Configuration</h2>
<h3>Client configuration.</h3>
<p>Edit /etc/racoon/racoon.conf and add the following to the bottom.</p>
<div class="pygments_murphy"><pre>include &quot;/opt/local/etc/cmdline-ipsec.conf&quot; ;
</pre></div>

<p>Create a configuration template file /opt/local/etc/cmdline-ipsec.conf.tmpl. I am using
a template because the remote side has a dynamic ip address and racoon does
not support DNS names only IP addresses, a custom script resolves the hostname
and then generates an updated racoon configuration from this template file with the
resolved IP address.</p>
<div class="pygments_murphy"><pre>remote %SERVERIP% {
        exchange_mode main;
        ca_type x509 &quot;/opt/local/etc/pki/cacert.pem&quot;;
        certificate_type x509 &quot;/opt/local/etc/pki/example.pem&quot; &quot;/opt/local/etc/pki/example.key.pem&quot;;
        proposal_check obey;
        mode_cfg off;
        dpd_delay 360;
        nat_traversal on;
        my_identifier asn1dn;
        ike_frag on;
        script &quot;/opt/local/bin/phase1-up.sh&quot; phase1_up;
        script &quot;/opt/local/bin/phase1-down.sh&quot; phase1_down;
        lifetime time 24 hour;
        passive off;
        proposal {
                encryption_algorithm aes256;
                hash_algorithm sha512;
                authentication_method rsasig;
                dh_group 2;
       }
}

sainfo anonymous {
        lifetime time 24 hour;
        pfs_group modp2048;
        encryption_algorithm aes256;
        authentication_algorithm hmac_sha1, hmac_sha256, hmac_sha512;
        compression_algorithm deflate ;
}
</pre></div>

<p>Create the phase1 up script /opt/local/bin/phase1-up.sh</p>
<div class="pygments_murphy"><pre><span class="c">#!/bin/sh</span>

<span class="c">#</span>
<span class="c"># sa-up.sh local configuration for a new SA</span>
<span class="c">#</span>
<span class="nv">PATH</span><span class="o">=</span>/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin
<span class="nv">MYIP</span><span class="o">=</span>10.128.1.2
<span class="nv">PROTECTEDNET</span><span class="o">=</span>192.168.1.0/24

<span class="nb">echo</span> <span class="nv">$@</span>
<span class="nb">echo</span> <span class="s2">&quot;LOCAL_ADDR = ${LOCAL_ADDR}&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;LOCAL_PORT = ${LOCAL_PORT}&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;REMOTE_ADDR = ${REMOTE_ADDR}&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;REMOTE_PORT = ${REMOTE_PORT}&quot;</span>

<span class="nv">LOCAL</span><span class="o">=</span><span class="s2">&quot;${LOCAL_ADDR}[${LOCAL_PORT}]&quot;</span>
<span class="nv">REMOTE</span><span class="o">=</span><span class="s2">&quot;${REMOTE_ADDR}[${REMOTE_PORT}]&quot;</span>

<span class="nb">echo</span> <span class="s2">&quot;</span>
<span class="s2">spdadd ${MYIP}/32[any] ${PROTECTEDNET}[any] any</span>
<span class="s2">       -P out ipsec esp/tunnel/${LOCAL}-${REMOTE}/require;</span>
<span class="s2">spdadd ${PROTECTEDNET} ${MYIP}[any] any</span>
<span class="s2">       -P in ipsec esp/tunnel/${REMOTE}-${LOCAL}/require;</span>
<span class="s2">&quot;</span> | setkey -c
</pre></div>

<p>Create the phase1 down script /opt/local/bin/phase1-down.sh</p>
<div class="pygments_murphy"><pre><span class="c">#!/bin/sh</span>

<span class="c">#</span>
<span class="c"># sa-down.sh local remove SA</span>
<span class="c">#</span>

<span class="nv">PATH</span><span class="o">=</span>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
<span class="nv">MYIP</span><span class="o">=</span>10.128.1.2
<span class="nv">PROTECTEDNET</span><span class="o">=</span>192.168.1.0/24

<span class="nb">echo</span> <span class="nv">$@</span>
<span class="nb">echo</span> <span class="s2">&quot;LOCAL_ADDR = ${LOCAL_ADDR}&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;LOCAL_PORT = ${LOCAL_PORT}&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;REMOTE_ADDR = ${REMOTE_ADDR}&quot;</span>
<span class="nb">echo</span> <span class="s2">&quot;REMOTE_PORT = ${REMOTE_PORT}&quot;</span>

<span class="nv">LOCAL</span><span class="o">=</span><span class="s2">&quot;${LOCAL_ADDR}[${LOCAL_PORT}]&quot;</span>
<span class="nv">REMOTE</span><span class="o">=</span><span class="s2">&quot;${REMOTE_ADDR}[${REMOTE_PORT}]&quot;</span>

<span class="nb">echo</span> <span class="s2">&quot;</span>
<span class="s2">deleteall ${REMOTE_ADDR} ${LOCAL_ADDR} esp;</span>
<span class="s2">deleteall ${LOCAL_ADDR} ${REMOTE_ADDR} esp; </span>
<span class="s2">spddelete ${MYIP}/32[any] ${PROTECTEDNET}[any] any</span>
<span class="s2">        -P out ipsec esp/tunnel/${LOCAL}-${REMOTE}/require;</span>
<span class="s2">spddelete ${PROTECTEDNET}[any] ${MYIP}[any] any</span>
<span class="s2">        -P in ipsec esp/tunnel/${REMOTE}-${LOCAL}/require;</span>
<span class="s2">&quot;</span> | setkey -c
</pre></div>

<p>Create the custom start script /opt/local/sbin/start-vpn</p>
<div class="pygments_murphy"><pre><span class="c">#!/bin/bash</span>
<span class="c">#</span>
<span class="c">#</span>
<span class="nv">SERVERNAME</span><span class="o">=</span><span class="s2">&quot;strongswan-example.dyndns.org&quot;</span>
<span class="nv">SERVERIP</span><span class="o">=</span><span class="k">$(</span>host <span class="nv">$SERVERNAME</span>|awk <span class="s1">&#39;{print $4}&#39;</span><span class="k">)</span>
<span class="nv">status</span><span class="o">=</span><span class="k">$(</span>racoonctl show-sa isakmp|wc -l|awk <span class="s1">&#39;{print $1}&#39;</span><span class="k">)</span>
<span class="k">if</span> <span class="o">[</span> <span class="s2">&quot;$status&quot;</span> !<span class="o">=</span> <span class="s2">&quot;2&quot;</span> <span class="o">]</span>; <span class="k">then</span>
<span class="k">   </span><span class="nb">echo</span> <span class="s2">&quot;Not connected, starting conn&quot;</span>
   sed -e <span class="s2">&quot;s:%SERVERIP%:${SERVERIP}:&quot;</span> <span class="se">\</span>
   /opt/local/etc/cmdline-ipsec.conf.tmpl &gt; /opt/local/etc/cmdline-ipsec.conf
   racoonctl reload-config
   racoonctl vpn-connect <span class="nv">$SERVERIP</span>
<span class="k">else</span>
<span class="k">   </span>racoonctl show-sa isakmp
   <span class="nb">echo</span> <span class="s2">&quot;Already connect, exiting&quot;</span>
<span class="k">fi</span>
</pre></div>

<p>Make the script executable</p>
<pre><code>chmod +x /opt/local/sbin/start-vpn
</code></pre>
<h3>Server configuration</h3>
<p>Update the ipsec.conf configuration from my previous post to add the following
conn</p>
<div class="pygments_murphy"><pre>conn rw
        leftcert=vpn.example.org.pem
        leftid=@vpn.example.org
        leftfirewall=yes
        right=%any
        rightsubnet=0.0.0.0/0
        rekey=yes
</pre></div>

<h2>Testing</h2>
<p>Open a command prompt and run the command, as root or using sudo.</p>
<pre><code>start-vpn
</code></pre>
<p>You should be able to connect to hosts on the protected network (192.168.1.0/24)</p>
<p>To stop the connection run the command.</p>
<pre><code>racoonctl vpn-disconnect strongswan-example.dyndns.org
</code></pre>
<h2>Related articles</h2>
<ul>
<li><a href="http://bit.ly/SN5z1k">IPSEC split tunneling VPN with Mac OSX and Strongswan 5 on Centos/RHEL 6</a></li>
<li><a href="http://bit.ly/WABVAZ">Iphone/Ipad/Mac OSX IPSEC VPN with Strongswan 5 on Centos/RHEL 6</a></li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>IPSEC split tunneling VPN with Mac OSX and Strongswan 5 on Centos/RHEL 6</title>
      <link>http://www.topdog.za.net/2012/09/01/ipsec-split-tunneling-vpn-with-mac-osx-and-strongswan-5-on-centos-rhel-6</link>
      <pubDate>Sat, 01 Sep 2012 10:08:00 SAST</pubDate>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[Mac OS X]]></category>
      <category><![CDATA[Howto]]></category>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[RHEL]]></category>
      <category><![CDATA[Linux]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[IPSEC]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/09/01/ipsec-split-tunneling-vpn-with-mac-osx-and-strongswan-5-on-centos-rhel-6</guid>
      <description>IPSEC split tunneling VPN with Mac OSX and Strongswan 5 on Centos/RHEL 6</description>
      <content:encoded><![CDATA[<h2>Introduction</h2>
<p>In my <a href="http://bit.ly/WABVAZ">previous post</a> i described how to setup an IPSEC VPN for use with Iphone,
Ipad and Mac OSX IPSEC VPN clients.</p>
<p>This post describes how to enable split tunneling which is supported by the
Mac OSX IPSEC client. Although split tunneling is considered insecure there
are cases where it is ideal to run split tunnels.</p>
<p>The scenario for this post is that you are connected to a LAN (10.128.0.0/24) with
internet access via a gateway on the LAN, you want to connect to a different
network 192.168.1.0/24 which is only accessible via VPN, but you want to retain
access to resources on the LAN while accessing the remote 192.168.1.0/24 network.</p>
<p>To follow this howto you need to have strongswan rpm with the <a href="http://bit.ly/NI7Mpx">attr-sql plugin</a>
enabled with a <a href="http://bit.ly/R5d4f8">sqlite</a> or <a href="http://bit.ly/R5d4f8">mysql</a> backed plugin enabled.
The <a href="http://bit.ly/NCWf0x">EPEL rpm</a> does not support these features at the time of writing. You need to build your own
custom strongswan rpm. You can download my <a href="http://bit.ly/OP75xw">spec file</a> and use it to build 
yourself the rpm.</p>
<h2>Installation</h2>
<p>Install the rpm</p>
<pre><code>rpm -Uvh strongswan-5.0.0-5.el6.x86_64.rpm
</code></pre>
<h2>Configuration</h2>
<p>Use the following configuration files, if you installation is new refer to
my <a href="http://bit.ly/WABVAZ">previous post</a> on how to create the certificates</p>
<h3>Create strongswan configuration</h3>
<p>This strongswan configuration allows you to use both certificates and pre shared
keys.</p>
<p>Add the username and password to /etc/strongswan/ipsec.secrets</p>
<div class="pygments_murphy"><pre>andrew : XAUTH &quot;5tr0ngp4ss0rd&quot;
</pre></div>

<p>Add the preshared key to /etc/strongswan/ipsec.secrets</p>
<div class="pygments_murphy"><pre>: PSK &quot;very long pre shared key difficlult to guess&quot;
</pre></div>

<p>Edit /etc/strongswan/ipsec.conf with the following content.</p>
<div class="pygments_murphy"><pre>config setup

conn %default
        ikelifetime=60m
        keylife=20m
        rekeymargin=3m
        keyingtries=1
        keyexchange=ikev1
        left=%defaultroute
        leftsubnet=192.168.1.0/24
        esp=aes256-sha256-modp2048,aes256-sha1!
        ike=aes256-sha1-modp1536,aes256-sha512-modp1024,aes256-sha1-modp1024!
        auto=add

conn rw-xauth
        leftcert=vpn.example.org.pem
        leftid=@vpn.example.org
        leftauth=pubkey
        leftfirewall=yes
        right=%any
        rightauth=pubkey
        rightauth2=xauth
        rightsourceip=%vpnclients
        rekey=yes

conn rw-xauth-psk
        leftfirewall=yes
        leftauth=psk
        right=%any
        rightauth=psk
        rightauth2=xauth
        rightsourceip=%vpnclients
        rekey=yes
</pre></div>

<p>Add the attr-sql plugin configuration to /etc/strongswan/strongswan.conf</p>
<div class="pygments_murphy"><pre>libhydra {
        plugins {
                attr-sql {
                        database = sqlite:///var/lib/strongswan/ipsec.db
                }
        }
}
</pre></div>

<h3>Restart the service</h3>
<p>Restart the service for the configurations to take effect.</p>
<pre><code>service strongswan restart
</code></pre>
<h3>Create sql attr Database</h3>
<p>Create a sqlite database to store the pool information.</p>
<pre><code>wget http://bit.ly/PyMe08
cat sqlite.sql | sqlite3 /var/lib/strongswan/ipsec.db
</code></pre>
<h3>Create a database based pool</h3>
<p>The pool will store the address range, the split tunnel network (192.168.1.0/24),
dns server to assign and a banner.</p>
<pre><code>strongswan pool --add vpnclients --start 192.168.2.0 --end 192.168.2.254 --timeout 48
strongswan pool --addattr dns --server 192.168.1.1 --pool vpnclients
strongswan pool --addattr unity_def_domain --string "example.org" --pool vpnclients
strongswan pool --addattr banner --string "example.org - all activity is monitored" --pool vpnclients
strongswan pool --addattr unity_split_include --subnet "192.168.1.0/255.255.255.0" --pool vpnclients
</code></pre>
<h2>Testing</h2>
<p>Configure your Mac OSX VPN client.</p>
<ul>
<li>Launch System preferences then select <strong>Network</strong> &gt; <strong>+</strong> &gt; <strong>Interface &gt; VPN</strong> &gt; <strong>VPN Type &gt; Cisco IPSEC</strong> &gt; <strong>Create</strong></li>
</ul>
<p>Set the Fields</p>
<pre><code>Description      Strongswan-IPSEC
Server           vpn.example.org
Account          andrew
Password         5tr0ngp4ss0rd
Use Certificate  ON
Certificate      name.example.org
</code></pre>
<p>Now when you connect, you will remain connected to your LAN as well as the remote network 10.128.0.0/24
if you run netstat -rn you will see the 10.128.0.0/24 network being routed via the tunnel interface.</p>
<h2>Related articles</h2>
<ul>
<li><a href="http://bit.ly/WABVAZ">Iphone/Ipad/Mac OSX IPSEC VPN with Strongswan 5 on Centos/RHEL 6</a></li>
<li><a href="http://bit.ly/Ujih5I">Mac OSX IPSEC VPN via command line using builtin Racoon client</a></li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Iphone/Ipad/Mac OSX IPSEC VPN with Strongswan 5 on Centos/RHEL 6</title>
      <link>http://www.topdog.za.net/2012/08/23/iphone-ipad-mac-osx-ipsec-vpn-with-strongswan-5-on-centos-rhel-6</link>
      <pubDate>Thu, 23 Aug 2012 10:21:00 SAST</pubDate>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[Mac OS X]]></category>
      <category><![CDATA[Howto]]></category>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[RHEL]]></category>
      <category><![CDATA[Linux]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[IPSEC]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/08/23/iphone-ipad-mac-osx-ipsec-vpn-with-strongswan-5-on-centos-rhel-6</guid>
      <description>Iphone/Ipad/Mac OSX IPSEC VPN with Strongswan 5 on Centos/RHEL 6</description>
      <content:encoded><![CDATA[<h2>Introduction</h2>
<p>This howto describes setting up an IPSEC VPN for use with the Iphone, Ipad and
Mac OSX VPN clients on Centos/RHEL 6. I am using the 5.x branch of Strongswan
which is now the mainline actively maintained branch. At the time of writing the
5.x EPEL package was only available in the testing repo.</p>
<p>The configuration should work both with NAT and without NAT on both sides, if
you are NATing on the server side make sure your forward UDP 500 and 4500 to
the machine running strongswan.</p>
<p>This howto uses example.org and 192.168.1.0/24 and 192.168.2.0/24 networks for
illustration purposes, you need to change these to suit your own setup.</p>
<h2>Install</h2>
<p>To access the EPEL packages you need to <a href="https://fedoraproject.org/wiki/EPEL/FAQ#howtouse">enable</a> the EPEL repo.
You are then able to install the strongswan package.</p>
<pre><code>yum install --enablerepo=epel-testing strongswan
</code></pre>
<p>Create the required configuration directories</p>
<pre><code>mkdir -p /etc/strongswan/ipsec.d/{aacerts,acerts,cacerts,certs,crls,ocspcerts,private}
</code></pre>
<h2>Configuration</h2>
<h3>Create a CA</h3>
<p>For RSA authentication you need to setup a CA which will issue the certificates to be
used by the server and the clients.</p>
<pre><code>cd /etc/pki/tls/misc
./CA -newca
echo 00 &gt; /etc/pki/CA/crlnumber
openssl ca -gencrl -out /etc/pki/CA/crl.pem
</code></pre>
<p>Install to strongswan directories</p>
<pre><code>ln -s /etc/pki/CA/cacert.pem /etc/strongswan/ipsec.d/cacerts/
ln -s /etc/pki/CA/crl.pem /etc/strongswan/ipsec.d/crls/
</code></pre>
<h3>Create the server certificate</h3>
<p>Apple clients require that the servers certificate subjectAltName attribute contain either
the server IP address or server DNS name. To ensure the server certificate contains the
subjectAltName attribute edit the openssl.cnf and set it under the [ usr_cert ] section</p>
<p>For DNS name set it to</p>
<div class="pygments_murphy"><pre>subjectAltName=DNS:vpn.example.org
</pre></div>

<p>For IP address set it to</p>
<div class="pygments_murphy"><pre>subjectAltName=IP:192.168.1.1
</pre></div>

<p>Now generate and sign the server certitifcate</p>
<pre><code>./CA -newreq
./CA -sign
</code></pre>
<p>Install to strongswan directories.</p>
<pre><code>mv newcert.pem /etc/strongswan/ipsec.d/certs/vpn.example.org.pem
mv newkey.pem /etc/strongswan/ipsec.d/private/vpn.example.org.key
</code></pre>
<p>Add the private key password to /etc/strongswan/ipsec.secrets</p>
<div class="pygments_murphy"><pre>: RSA vpn.example.org.key &quot;p4ssw0rd&quot;
</pre></div>

<h3>Create the client certificate</h3>
<p>This is the certificate that will be used by you VPN clients ie Ipad/Iphone, edit the openssl.cnf
and comment out the subjectAltName attribute setting.</p>
<p>Now generate and sign the client certificate, do this for all the clients you expect to use.</p>
<pre><code>./CA -newreq
./CA -sign
openssl pkcs12 -export -in ipad.example.org.pem -inkey ipad.example.org.key \
 -certfile /etc/pki/CA/cacert.pem -out ipad.p12
</code></pre>
<p>You now need to import the CA certificate and the client p12 certificate on to the device. You
need to download the <a href="https://support.apple.com/kb/DL1465">Iphone configuration utility</a> and
use it to import the certificates to your device.</p>
<p><img alt="Iphone configuration utility;" src="/imgs/iphone-config.png" /></p>
<p>Add the username and password to /etc/strongswan/ipsec.secrets</p>
<div class="pygments_murphy"><pre>andrew : XAUTH &quot;5tr0ngp4ss0rd&quot;
</pre></div>

<h3>Create strongswan configuration</h3>
<p>Edit /etc/strongswan/ipsec.conf with the following content.</p>
<div class="pygments_murphy"><pre>config setup

conn %default
        ikelifetime=60m
        keylife=20m
        rekeymargin=3m
        keyingtries=1
        keyexchange=ikev1
        left=%defaultroute
        leftsubnet=192.168.1.0/24
        auto=add

conn rw-xauth
        leftcert=vpn.example.org.pem
        leftid=@vpn.example.org
        leftauth=pubkey
        leftfirewall=yes
        right=%any
        rightauth=pubkey
        rightauth2=xauth
        rightsourceip=192.168.2.0/24
</pre></div>

<p>The above setup assumes the network behind the vpn is 192.168.1.0/24 and virtual IP addresses will
be assigned to VPN clients from the 192.168.2.0/24 network block.</p>
<h3>Enable packet forwarding</h3>
<p>If your system is not setup for packet forwarding enable it.</p>
<pre><code>echo 1 &gt; /proc/sys/net/ipv4/ip_forward
</code></pre>
<p>Edit /etc/sysctl.conf and set</p>
<div class="pygments_murphy"><pre>net.ipv4.ip_forward = 1
</pre></div>

<h2>Testing</h2>
<p>Start strongswan.</p>
<pre><code>service strongswan start
</code></pre>
<p>Check /var/log/messages and /var/log/secure for any errors.</p>
<h3>Ipad configuration</h3>
<ul>
<li>Launch Settings then select <strong>General</strong> &gt; <strong>Network</strong> &gt; <strong>VPN</strong> &gt; <strong>Add VPN Configuration</strong></li>
<li>Toggle <strong>VPN</strong> type to <strong>IPSec</strong></li>
</ul>
<p>Set the Fields</p>
<pre><code>Description      Strongswan-IPSEC
Server           vpn.example.org
Account          andrew
Password         5tr0ngp4ss0rd
Use Certificate  ON
Certificate      ipad.example.org
</code></pre>
<p>A VPN connection should now be possible by toggling <strong>VPN</strong> to <strong>ON</strong> under <strong>Settings</strong> &gt; <strong>VPN</strong>.</p>
<h2>Related articles</h2>
<ul>
<li><a href="http://bit.ly/SN5z1k">IPSEC split tunneling VPN with Mac OSX and Strongswan 5 on Centos/RHEL 6</a></li>
<li><a href="http://bit.ly/Ujih5I">Mac OSX IPSEC VPN via command line using builtin Racoon client</a></li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Mac OS X Alias IP addresses</title>
      <link>http://www.topdog.za.net/2012/06/11/mac-os-x-alias-ip-addresses</link>
      <pubDate>Mon, 11 Jun 2012 07:55:00 SAST</pubDate>
      <category><![CDATA[Mac OS X]]></category>
      <category><![CDATA[Tips]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/06/11/mac-os-x-alias-ip-addresses</guid>
      <description>Mac OS X Alias IP addresses</description>
      <content:encoded><![CDATA[<p>To create an IP alias</p>
<pre><code>ifconfig en0 alias 10.0.0.1 255.255.255.0
</code></pre>
<p>To remove an IP alias</p>
<pre><code>ifconfig en0 -alias 10.0.0.1 255.255.255.0
</code></pre>]]></content:encoded>
    </item>
  </channel>
</rss>
