<?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>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>Centos 6 Bonded network interfaces</title>
      <link>http://www.topdog.za.net/2013/02/01/centos-6-bonded-network-interfaces</link>
      <pubDate>Fri, 01 Feb 2013 07:40:00 SAST</pubDate>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[Centos]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2013/02/01/centos-6-bonded-network-interfaces</guid>
      <description>Centos 6 Bonded network interfaces</description>
      <content:encoded><![CDATA[<p>Bonding allows you to aggregate multiple ports, providing redundancy,
fault tolerance and load balancing.</p>
<p>There are various types of bonding available but i will show how to
bond in mode 1 which is active-backup. If your interested in the other
available types please refer to the
<a href="https://www.kernel.org/doc/Documentation/networking/bonding.txt">documentation</a>.</p>
<p>In this setup i have two connections to different switches in case one
fails the other takes over and services are not disrupted.</p>
<h2>Setup bonded interface</h2>
<p>Create a file in /etc/modprobe.d called bond.conf and add the following</p>
<div class="pygments_murphy"><pre><span class="nb">alias </span>bond0 bonding
</pre></div>

<p>Create the bonded interface file /etc/sysconfig/network-scripts/ifcfg-bond0
with the following contents</p>
<div class="pygments_murphy"><pre><span class="nv">DEVICE</span><span class="o">=</span>bond0
<span class="nv">IPADDR</span><span class="o">=</span>xxx.xxx.xxx.xxx
<span class="nv">NETMASK</span><span class="o">=</span>xxx.xxx.xxx.xxx
<span class="nv">ONBOOT</span><span class="o">=</span>yes
<span class="nv">BOOTPROTO</span><span class="o">=</span>none
<span class="nv">USERCTL</span><span class="o">=</span>no
<span class="nv">BONDING_OPTS</span><span class="o">=</span><span class="s2">&quot;bond0 miimon=80 mode=1&quot;</span>
</pre></div>

<p>Modify the interfaces you want to bond to look like:</p>
<div class="pygments_murphy"><pre><span class="nv">DEVICE</span><span class="o">=</span>ethX
<span class="nv">ONBOOT</span><span class="o">=</span>yes
<span class="nv">BOOTPROTO</span><span class="o">=</span>none
<span class="nv">USERCTL</span><span class="o">=</span>no
<span class="nv">MASTER</span><span class="o">=</span>bond0
<span class="nv">SLAVE</span><span class="o">=</span>yes
</pre></div>

<p>Restart networking for the changes to take effect:</p>
<pre><code>service network restart
</code></pre>
<h2>Checking the status</h2>
<p>You can check the status of the interface by running:</p>
<pre><code>cat /proc/net/bonding/bond0
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>How to update man keywords database</title>
      <link>http://www.topdog.za.net/2013/01/16/how-to-update-man-keywords-database</link>
      <pubDate>Wed, 16 Jan 2013 07:40:00 SAST</pubDate>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[Ubuntu]]></category>
      <category><![CDATA[Sysadmin]]></category>
      <category><![CDATA[Unix]]></category>
      <category><![CDATA[RHEL]]></category>
      <category><![CDATA[Linux]]></category>
      <category><![CDATA[Tips]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2013/01/16/how-to-update-man-keywords-database</guid>
      <description>How to update man keywords database</description>
      <content:encoded><![CDATA[<p>Man keywords database allow you to search for man pages using keywords,
the database needs to be updated when ever man pages are added or removed.</p>
<p>This is how you do it for various *nix types.</p>
<h2>Debian/Ubuntu/SUSE</h2>
<pre><code>mandb
</code></pre>
<h2>RHEL/CENTOS/SL/Fedora</h2>
<pre><code>makewhatis
</code></pre>
<h2>AIX/Solaris/HP-UX</h2>
<pre><code>catman -w
</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>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>Fix Bind error (broken trust chain) resolving</title>
      <link>http://www.topdog.za.net/2012/08/22/fix-bind-error--broken-trust-chain--resolving</link>
      <pubDate>Wed, 22 Aug 2012 20:21:00 SAST</pubDate>
      <category><![CDATA[Tips]]></category>
      <category><![CDATA[RHEL]]></category>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[DNS]]></category>
      <category><![CDATA[Linux]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/08/22/fix-bind-error--broken-trust-chain--resolving</guid>
      <description>Fix Bind error (broken trust chain) resolving</description>
      <content:encoded><![CDATA[<p>This Bind named issue results in queries failing and log messages
such as the following being logged</p>
<pre><code>error (no valid KEY) resolving 'dlv.isc.org/DNSKEY/IN': 156.154.101.23#53
error (broken trust chain) resolving './NS/IN': 193.0.14.129#53
</code></pre>
<p>The issue is caused by the date on the system falling out of sync, which
causes DLV validation to fail.</p>
<p>This issue can be fixed by doing the following on Centos / RHEL.</p>
<pre><code>ntpdate ntp.pool.org
hwclock --systohc
rm /var/named/dynamic/managed-keys.bind*
service named restart
</code></pre>
<p>Name resolution so now work without any issues.</p>]]></content:encoded>
    </item>
    <item>
      <title>Setup DKIM on Postfix with OpenDKIM</title>
      <link>http://www.topdog.za.net/2012/04/29/setup-dkim-on-postfix-with-opendkim</link>
      <pubDate>Sun, 29 Apr 2012 06:50:00 SAST</pubDate>
      <category><![CDATA[Postfix]]></category>
      <category><![CDATA[Howto]]></category>
      <category><![CDATA[DKIM]]></category>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[Email]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2012/04/29/setup-dkim-on-postfix-with-opendkim</guid>
      <description>Setup DKIM on Postfix with OpenDKIM</description>
      <content:encoded><![CDATA[<h2>Introduction</h2>
<p>DKIM is an authentication framework which stores public-keys in DNS and
digitally signs emails on a domain basis. It was created as a result of
merging Yahoo's domainkeys and Cisco's Identified Internet mail
specification. It is defined in RFC 4871.</p>
<p>I previously <a href="http://www.topdog.za.net/2009/03/10/setup-dkim-on-postfix-with-dkim-milter/">wrote</a>
about setting up DKIM using dkim-milter, dkim-milter has since been depreciated.</p>
<p>We will be using the <a href="http://www.opendkim.org/">OpenDKIM</a> implementation
Centos, OpenDKIM is a fork of dkim-milter.</p>
<h2>Installation</h2>
<pre><code>yum install opendkim
</code></pre>
<h2>Generate the Keys</h2>
<pre><code>opendkim-genkey -d &lt;domain_name&gt; -s &lt;selector&gt;
</code></pre>
<p>Replace <domain_name> with the domain name you will be signing the mail for,
and <selector> with a selector name it can be anything (but just one word).
The command will create two files.</p>
<ul>
<li>
<p><selector>.txt - contains the public key you publish via DNS</p>
</li>
<li>
<p><selector>.private - the private key you use for signing your email</p>
</li>
</ul>
<p>Create a sub directory in /etc/opendkim/keys to store your key, i prefer to
use the domain name <domain_name> as the sub directory name.</p>
<pre><code># mv &lt;selector&gt;.private /etc/opendkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
# chmod 600 /etc/opendkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
# chown opendkim.opendkim /etc/opendkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
</code></pre>
<h2>DNS Setup</h2>
<p>You need to publish your public key via DNS, client servers use this key to
verify your signed email. The contents of <selector>.txt is the record you
need to add to your zone file a sample, is below (it uses default as the
selector and example.com as the domain_name)</p>
<pre><code>default._domainkey IN TXT "v=DKIM1; r=postmaster; g=*; k=rsa;
p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNA
DCBiQKBgQDG81CNNVOlWwfhENOZEnJKNlikTB3Dnb5kUC8/zvht/S8SQnx+YgZ/KG7KOus0By8cIDDv
wn3ElVRVQ6Jhz/HcvPU5DXCAC5owLBf/gX5tvAnjF1vSL8ZBetxquVHyJQpMFH3VW37m/mxPTGmDL+z
JVW+CKpUcI8BJD03iW2l1CwIDAQAB" ; ----- DKIM default for example.com
</code></pre>
<h2>Configuration</h2>
<p>Edit /etc/opendkim.conf comment out "KeyFile /etc/opendkim/keys/default.private"
and uncomment "#KeyTable       /etc/opendkim/KeyTable"</p>
<p>Edit the file /etc/opendkim/KeyTable and add your domain using the following format</p>
<pre><code>&lt;selector&gt;._domainkey.&lt;domain_name&gt; &lt;domain_name&gt;:&lt;selector&gt;:/etc/opendkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
</code></pre>
<p>Add your servers IP addresses to /etc/opendkim/TrustedHosts</p>
<p>More advanced configuration options can be set in the file /etc/opendkim.conf</p>
<h2>Configure Postfix</h2>
<p>You need to add the following options to the postfix main.cf file to enable it
to use the milter.</p>
<pre><code>smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
</code></pre>
<p>Append the OpenDKIM options to the existing milters if you have other milters
already configured.</p>
<p>Start OpenDKIM and restart postfix</p>
<pre><code># service opendkim start
# service postfix restart
</code></pre>
<h2>Testing</h2>
<p>Send an email to sa-test@sendmail.net or autorespond+dkim@dk.elandsys.com, you
will receive a response stating if your setup is working correctly. If you
have a Gmail account you can send an email to that account and look at the
message details similar to the picture below, you should see signed-by “your
domain” if your setup was done correctly.</p>
<p><a href="/media/google.jpg"><img alt="DKIM signed mail in google" src="/media/google.jpg" /></a></p>]]></content:encoded>
    </item>
    <item>
      <title>Setup DKIM on Postfix with dkim-milter</title>
      <link>http://www.topdog.za.net/2009/03/10/setup-dkim-on-postfix-with-dkim-milter</link>
      <pubDate>Tue, 10 Mar 2009 23:54:00 SAST</pubDate>
      <category><![CDATA[Postfix]]></category>
      <category><![CDATA[Howto]]></category>
      <category><![CDATA[DKIM]]></category>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[Email]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2009/03/10/setup-dkim-on-postfix-with-dkim-milter</guid>
      <description>Setup DKIM on Postfix with dkim-milter</description>
      <content:encoded><![CDATA[<h2>Introduction</h2>
<p>DKIM is an authentication framework which stores public-keys in DNS and digitally signs emails on a domain basis. It was created as a result of merging Yahoo's domainkeys and Cisco's Identified Internet mail specification. It is defined in RFC 4871.</p>
<p>We will be using the milter implementation of dkim <a href="http://dkim-milter.sf.net">http://dkim-milter.sf.net</a> on centos 5.3.</p>
<p>This howto has been updated to allow for the following.</p>
<ul>
<li>Multiple domains using different keys</li>
<li>Same domain using different selectors</li>
<li>Selective signing of email</li>
</ul>
<p>Older versions are provided below for reference.</p>
<h2>Installation</h2>
<p>I provide Centos rpms for Dkim-milter at <a href="http://www.topdog-software.com/oss/">http://www.topdog-
software.com/oss/</a> so we will install the
latest version.</p>
<p>Install the rpm, ( 32bit and 64bit intel supported )</p>
<pre><code># wget http://www.topdog-software.com/oss/roundcube/andrew_topdog-software.com_key.txt
# rpm --import andrew_topdog-software.com_key.txt
# http://www.topdog-software.com/oss/dkim-milter/dkim-milter-2.8.2-2.$(uname -i).rpm
</code></pre>
<h2>Generate the Keys</h2>
<pre><code># dkim-genkey -d &lt;domain_name&gt; -s &lt;selector&gt; -t
</code></pre>
<p>Replace <domain_name> with the domain name you will be signing the mail for,
and <selector> with a selector name it can be anything (but just one word).
The command will create two files.</p>
<ul>
<li>
<p><selector>.txt - contains the public key you publish via DNS</p>
</li>
<li>
<p><selector>.private - the private key you use for signing your email</p>
</li>
</ul>
<p>Create a sub directory in /etc/mail/dkim/keys to store your key, i prefer to
use the domain name <domain_name> as the sub directory name.</p>
<pre><code># mv &lt;selector&gt;.private /etc/mail/dkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
# chmod 600 /etc/mail/dkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
# chown dkim-milt.dkim-milt /etc/mail/dkim/keys/&lt;domain_name&gt;/&lt;selector&gt;.pem
</code></pre>
<h2>DNS Setup</h2>
<p>You need to publish your public key via DNS, client servers use this key to
verify your signed email. The contents of <selector>.txt is the record you
need to add to your zone file a sample, is below (it uses default as the
selector and topdog-software.com as the domain_name)</p>
<pre><code>default._domainkey IN TXT "v=DKIM1; g=*; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNA
DCBiQKBgQDG81CNNVOlWwfhENOZEnJKNlikTB3Dnb5kUC8/zvht/S8SQnx+YgZ/KG7KOus0By8cIDDv
wn3ElVRVQ6Jhz/HcvPU5DXCAC5owLBf/gX5tvAnjF1vSL8ZBetxquVHyJQpMFH3VW37m/mxPTGmDL+z
JVW+CKpUcI8BJD03iW2l1CwIDAQAB" ; ----- DKIM default for topdog-software.com
</code></pre>
<p>Also add this to your zone file. (This sets your policy see <a href="http://www.sendmail.org/dkim/wizard">http://www.sendmail.org/dkim/wizard</a> for an explanation or refer to the RFC)</p>
<pre><code>_adsp._domainkey    IN  TXT "dkim=unknown"
</code></pre>
<h2>Configuration</h2>
<p>Edit the file /etc/mail/dkim/keylist and add your domain using the following format</p>
<pre><code>*@&lt;domain_name&gt;:&lt;domain_name&gt;:/etc/mail/dkim/keys/&lt;domain_name&gt;/&lt;selector&gt;
#sign only for andrew
andrew@&lt;domain_name&gt;:&lt;domain_name&gt;:/etc/mail/dkim/keys/&lt;domain_name&gt;/&lt;selector&gt;
</code></pre>
<p>Add your servers IP addresses to /etc/mail/dkim/trusted-hosts</p>
<p>More advanced configuration options can be set in the file /etc/dkim-filter.conf (Refer to the file and the man pages for details)</p>
<h2>Configure Postfix</h2>
<p>You need to add the following options to the postfix main.cf file to enable it
to use the milter.</p>
<pre><code>smtpd_milters = inet:localhost:20209
non_smtpd_milters = inet:localhost:20209
</code></pre>
<p>Append the dkim-milter options to the existing milters if you have other
milters already configured.</p>
<p>Start dkim-milter and restart postfix</p>
<pre><code># service dkim-milter start
# service postfix restart
</code></pre>
<h2>Testing</h2>
<p>Send an email to sa-test@sendmail.net or autorespond+dkim@dk.elandsys.com, you
will receive a response stating if your setup is working correctly. If you
have a Gmail account you can send an email to that account and look at the
message details similar to the picture below, you should see signed-by “your
domain” if your setup was done correctly.</p>
<p><a href="/media/google.jpg"><img alt="DKIM signed mail in google" src="/media/google.jpg" /></a></p>
<h2>Updates</h2>
<p>Updated rpms are always provided at <a href="http://www.topdog-software.com/oss/dkim-milter/">http://www.topdog-software.com/oss/dkim-milter/</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>
