<?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>Testing SSL client certificate authentication with curl</title>
      <link>http://www.topdog.za.net/2013/03/28/testing-ssl-client-certificate-authentication-with-curl</link>
      <pubDate>Thu, 28 Mar 2013 07:40:00 SAST</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Security]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2013/03/28/testing-ssl-client-certificate-authentication-with-curl</guid>
      <description>Testing SSL client certificate authentication with curl</description>
      <content:encoded><![CDATA[<p>When using SSL client certificate authentication you may need to
test it using command line tools.</p>
<p>To do so run the following command:</p>
<pre><code>curl -v -s -k --key client.key --cert client.pem https://servername
</code></pre>
<p>Thats it.</p>]]></content:encoded>
    </item>
    <item>
      <title>Setup a OpenVPN server on Centos 6</title>
      <link>http://www.topdog.za.net/2013/02/02/setup-a-openvpn-server-on-centos-6</link>
      <pubDate>Sat, 02 Feb 2013 07:40:00 SAST</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[Centos]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2013/02/02/setup-a-openvpn-server-on-centos-6</guid>
      <description>Setup a OpenVPN server on Centos 6</description>
      <content:encoded><![CDATA[<h2>EPEL Repository</h2>
<p>OpenVPN 2 is available for Centos from the EPEL repository, so you
need to have EPEL enabled.</p>
<p>If you do not have EPEL enabled run:</p>
<pre><code>rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
</code></pre>
<h2>Installation</h2>
<p>To install OpenVPN run:</p>
<pre><code>yum install openvpn lzo -y
</code></pre>
<h2>Configuration</h2>
<p>Setup the SSL CA and keys:</p>
<pre><code>cp -r /usr/share/openvpn/easy-rsa/2.0 /etc/openvpn/open-rsa
</code></pre>
<p>Create and customize the <code>vars</code> file <code>/etc/openvpn/open-rsa/vars</code>,
Make sure you change the <code>KEY_</code> values to your own settings</p>
<div class="pygments_murphy"><pre><span class="nb">export </span><span class="nv">EASY_RSA</span><span class="o">=</span><span class="s2">&quot;`pwd`&quot;</span>
<span class="nb">export </span><span class="nv">OPENSSL</span><span class="o">=</span><span class="s2">&quot;openssl&quot;</span>
<span class="nb">export </span><span class="nv">PKCS11TOOL</span><span class="o">=</span><span class="s2">&quot;pkcs11-tool&quot;</span>
<span class="nb">export </span><span class="nv">GREP</span><span class="o">=</span><span class="s2">&quot;grep&quot;</span>
<span class="nb">export </span><span class="nv">KEY_CONFIG</span><span class="o">=</span><span class="sb">`</span><span class="nv">$EASY_RSA</span>/whichopensslcnf <span class="nv">$EASY_RSA</span><span class="sb">`</span>
<span class="nb">export </span><span class="nv">KEY_DIR</span><span class="o">=</span><span class="s2">&quot;/etc/openvpn/keys&quot;</span>
<span class="nb">echo </span>NOTE: If you run ./clean-all, I will be doing a rm -rf on <span class="nv">$KEY_DIR</span>
<span class="nb">export </span><span class="nv">PKCS11_MODULE_PATH</span><span class="o">=</span><span class="s2">&quot;dummy&quot;</span>
<span class="nb">export </span><span class="nv">PKCS11_PIN</span><span class="o">=</span><span class="s2">&quot;dummy&quot;</span>
<span class="nb">export </span><span class="nv">KEY_SIZE</span><span class="o">=</span>1024
<span class="nb">export </span><span class="nv">CA_EXPIRE</span><span class="o">=</span>3650
<span class="nb">export </span><span class="nv">KEY_EXPIRE</span><span class="o">=</span>3650
<span class="nb">export </span><span class="nv">KEY_COUNTRY</span><span class="o">=</span><span class="s2">&quot;ZA&quot;</span>
<span class="nb">export </span><span class="nv">KEY_PROVINCE</span><span class="o">=</span><span class="s2">&quot;Gauteng&quot;</span>
<span class="nb">export </span><span class="nv">KEY_CITY</span><span class="o">=</span><span class="s2">&quot;Johannesburg&quot;</span>
<span class="nb">export </span><span class="nv">KEY_ORG</span><span class="o">=</span><span class="s2">&quot;Topdog-software&quot;</span>
<span class="nb">export </span><span class="nv">KEY_EMAIL</span><span class="o">=</span><span class="s2">&quot;andrew@topdog.za.net&quot;</span>
<span class="nb">export </span><span class="nv">KEY_CN</span><span class="o">=</span><span class="s2">&quot;Topdog-software OpenVPN CA&quot;</span>
<span class="nb">export </span><span class="nv">KEY_NAME</span><span class="o">=</span><span class="s2">&quot;tdss&quot;</span>
<span class="nb">export </span><span class="nv">KEY_OU</span><span class="o">=</span><span class="s2">&quot;Topdog-software&quot;</span>
</pre></div>

<p>Create the keys directory:</p>
<pre><code>mkdir /etc/openvpn/keys
</code></pre>
<p>Create the CA:</p>
<pre><code>cd /etc/openvpn/open-rsa
source ./vars
./clean-all
./build-ca
</code></pre>
<p>Create the servers SSL certificate (replace <code>vpn.home.topdog-software.com</code> with
name of your server):</p>
<pre><code>./build-key-server vpn.home.topdog-software.com
</code></pre>
<p>Generate Diffie Hellman parameters:</p>
<pre><code>./build-dh
</code></pre>
<p>Create the leases file:</p>
<pre><code>touch /etc/openvpn/ipp.txt
</code></pre>
<p>Create the configuration file <code>/etc/openvpn/server.conf</code>:</p>
<div class="pygments_murphy"><pre>port 1194
proto udp
dev tun
ca keys/ca.crt
cert keys/vpn.home.topdog-software.com.crt
key keys/vpn.home.topdog-software.com.key
dh keys/dh1024.pem
cipher AES-128-CBC
server 10.0.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
client-config-dir ccd
keepalive 10 120
comp-lzo
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
</pre></div>

<p>Create iptables rules to allow traffic through:</p>
<div class="pygments_murphy"><pre>*filter
..
..
-A INPUT -p udp -m state --state NEW -m udp --dport 1194 -j ACCEPT
-A FORWARD -i tun+ -o eth0 -j ACCEPT
-A FORWARD -i eth0 -o tun+ -j ACCEPT
</pre></div>

<p>Enable packet forwarding:</p>
<pre><code>echo 1 &gt; /proc/sys/net/ipv4/ip_forward
</code></pre>
<p>Make it permanent add the following to <code>/etc/sysctl.conf</code>:</p>
<div class="pygments_murphy"><pre>net.ipv4.ip_forward = 1
</pre></div>

<p>Your OpenVPN should be ready to go, start OpenVPN:</p>
<pre><code>service openvpn start
</code></pre>
<h2>Client configuration</h2>
<p>Each client requires a certificate &amp; key pairing, lets create one:</p>
<pre><code>./build-key client1.home.topdog-software.com
</code></pre>
<p>Copy the <code>client1.home.topdog-software.com.crt</code>, <code>ca.crt</code> and
<code>client1.home.topdog-software.com.key</code> files to the OpenVPN keys
directory on the client.</p>
<p>Create the client OpenVPN configuration <code>/etc/openvpn/server.conf</code>:</p>
<div class="pygments_murphy"><pre>remote vpn.home.topdog-software.com 1194
client 
remote-cert-tls server 
dev tun0 
proto udp
resolv-retry infinite 
nobind 
persist-key 
persist-tun 
float 
ca keys/ca.crt 
cert keys/client1.home.topdog-software.com.crt
key keys/client1.home.topdog-software.com.key
cipher AES-128-CBC
comp-lzo
status /var/log/openvpn-client.log
</pre></div>

<h2>Static addresses</h2>
<p>If you want some clients to get static addresses:</p>
<pre><code>mkdir /etc/openvpn/ccd
</code></pre>
<p>Create a client file for each of the clients you want to get a static
address in <code>/etc/openvpn/ccd</code> the file name should match the CN in
the client certificate.</p>
<div class="pygments_murphy"><pre>ifconfig-push 10.0.0.2 10.0.0.1
</pre></div>]]></content:encoded>
    </item>
    <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>Strongswan now supports PAM authentication</title>
      <link>http://www.topdog.za.net/2012/11/07/strongswan-now-supports-pam-authentication</link>
      <pubDate>Wed, 07 Nov 2012 07:40:00 SAST</pubDate>
      <category><![CDATA[Centos]]></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/11/07/strongswan-now-supports-pam-authentication</guid>
      <description>Strongswan now supports PAM authentication</description>
      <content:encoded><![CDATA[<p>Strongswan release 5.0.1 includes a XAuth PAM plugin which
requests username/password XAuth credentials and verifies them
against Pluggable Authentication Modules (PAM).</p>
<p>This plugin is not enabled by default to enable it you need
to add the following to your ./configure options</p>
<pre><code>--enable-xauth-pam
</code></pre>
<p>You do require the pam development headers and libraries on your
build machine to successfully compile.</p>
<h2>System Configuration</h2>
<p>The plugin is configurable in the strongswan.conf file, you are
able to change the pam service that is used for authentication.</p>
<p>By default the login pam service is used for authentication.</p>
<p>I will create a new service called ipsec for demonstration.</p>
<div class="pygments_murphy"><pre>charon {
    plugins{
        xauth-pam {
            pam_service = ipsec
        }
    }
}
</pre></div>

<p>The pam service configuration file is as follows.</p>
<div class="pygments_murphy"><pre>#%PAM-1.0
# /etc/pam.d/ipsec
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid &gt;= 500 quiet
auth        required      pam_deny.so

account     required      pam_unix.so
account     sufficient    pam_localuser.so
account     sufficient    pam_succeed_if.so uid &lt; 500 quiet
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3 type=
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
</pre></div>

<p>Now to use PAM authentication in your connections you set for XAuth:</p>
<pre><code>rightauth2=xauth-pam
</code></pre>
<p>Hybrid Authentication:</p>
<pre><code>rightauth=xauth-pam
</code></pre>
<p>You are good to go and should be able to use any pam module to
authenticate your users to your VPN. The options are endless: SQL,
LDAP, RADIUS, LOCAL etc.</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>
<li><a href="http://bit.ly/SN5z1k">IPSEC split tunneling VPN with Mac OSX and Strongswan 5 on Centos/RHEL 6</a></li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Strongswan now supports Cisco unity extensions</title>
      <link>http://www.topdog.za.net/2012/11/07/strongswan-now-supports-cisco-unity-extensions</link>
      <pubDate>Wed, 07 Nov 2012 07:40:00 SAST</pubDate>
      <category><![CDATA[Centos]]></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/11/07/strongswan-now-supports-cisco-unity-extensions</guid>
      <description>Strongswan now supports Cisco unity extensions</description>
      <content:encoded><![CDATA[<p>I previously <a href="http://bit.ly/OIHOq4">wrote</a> about setting up split
tunneling on Strongswan using the <a href="http://bit.ly/NI7Mpx">attr-sql plugin</a></p>
<p>With the release of Strongswan 5.0.1 it is no longer the only way
to support split tunneling.</p>
<p>Strongswan 5.0.1 introduces the unity plugin which allows for the
configuration of split tunneling either using a charon option or
using the attr plugin which is enabled by default.</p>
<p>The unity plugin is not enabled by default to enable it you need
to add the following to your ./configure options</p>
<pre><code>--enable-unity
</code></pre>
<h2>Charon option</h2>
<p>To enable this option you need to edit the strongswan.conf file
and set</p>
<div class="pygments_murphy"><pre>charon {
    # ... other options
    cisco_unity = yes
    #...
}
</pre></div>

<p>As a client strongswan will install policies only for the received
Split-Include attributes and IPsec bypass policies for received
Local-LAN attributes.</p>
<p>As a server strongswan will send Split-Include attributes for leftsubnet
definitions containing multiple subnets to clients that support the
IKEv1 Cisco Unity Extensions.</p>
<h2>Attr plugin option</h2>
<p>It is also possible to configure split tunneling using the attr plugin.
Two new options have been added:</p>
<ul>
<li>split-include - Comma-separated list of subnets to tunnel</li>
<li>split-exclude - Comma-separated list of subnets not to tunnel</li>
</ul>
<div class="pygments_murphy"><pre>charon {
    # ... other options
    split-include = 192.168.1.0/24, 172.16.0.0/16
    split-exclude = 10.128.0.0/16
    #...
}
</pre></div>

<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>
<li><a href="http://bit.ly/SN5z1k">IPSEC split tunneling VPN with Mac OSX and Strongswan 5 on Centos/RHEL 6</a></li>
</ul>]]></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>MailScanner Ubuntu and Debian packages</title>
      <link>http://www.topdog.za.net/2012/09/10/mailscanner-ubuntu-and-debian-packages</link>
      <pubDate>Mon, 10 Sep 2012 07:39:00 SAST</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[Email]]></category>
      <category><![CDATA[Linux]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/09/10/mailscanner-ubuntu-and-debian-packages</guid>
      <description>MailScanner Ubuntu and Debian packages</description>
      <content:encoded><![CDATA[<p>The Debian and Ubuntu MailScanner packages have not been maintained for a long time.
Recently both distributions dropped support for MailScanner within their repo's.</p>
<p>The <a href="http://bit.ly/UE4N6D">Baruwa project</a> provides up to date deb packages for both
distributions.</p>
<p>Packages are available for:</p>
<ul>
<li>squeeze</li>
<li>wheezy</li>
<li>sid</li>
<li>lucid</li>
<li>maverick</li>
<li>natty</li>
<li>oneiric</li>
<li>precise</li>
<li>quantal</li>
</ul>
<h2>Usage</h2>
<p>To use the packages you need to enable the baruwa apt repo.</p>
<pre><code>cat &gt; /etc/apt/sources.list.d/baruwa.list &lt;&lt; 'EOF'
deb http://apt.baruwa.org/ubuntu precise main
EOF
</code></pre>
<p><strong>Change "precise" to your specific release name</strong></p>
<p>Add the repo's GPG key</p>
<pre><code>wget -O - http://apt.baruwa.org/baruwa-apt-keys.gpg | apt-key add -
</code></pre>
<p>Then run</p>
<pre><code>apt-get update
apt-get install mailscanner
</code></pre>
<h2>Support &amp; Assistance</h2>
<p>Use the friendly Baruwa project <a href="http://bit.ly/Rwj1I4">mailing list</a> </p>]]></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>MailScanner book now free</title>
      <link>http://www.topdog.za.net/2012/05/01/mailscanner-book-now-free</link>
      <pubDate>Tue, 01 May 2012 12:39:00 SAST</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Security]]></category>
      <category><![CDATA[Email]]></category>
      <category><![CDATA[Linux]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/05/01/mailscanner-book-now-free</guid>
      <description>MailScanner book now free</description>
      <content:encoded><![CDATA[<p><a href="http://www.jules.fm/">Julian Field</a> the author of <a href="http://www.mailscanner.info/">MailScanner</a>
and the of the MailScanner book has just announced that the MailScanner Book is now available for free.</p>
<p>So head off and <a href="http://www.mailscanner.info/files/MailScanner-Guide.pdf">get your copy</a>.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
