<?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>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>How to setup a network install server</title>
      <link>http://www.topdog.za.net/2008/01/29/how-to-setup-a-network-install-server</link>
      <pubDate>Tue, 29 Jan 2008 20:53:00 SAST</pubDate>
      <category><![CDATA[Kickstart]]></category>
      <category><![CDATA[Howto]]></category>
      <category><![CDATA[RHEL]]></category>
      <category><![CDATA[Centos]]></category>
      <category><![CDATA[Linux]]></category>
      <guid isPermaLink="true">http://www.topdog.za.net/2008/01/29/how-to-setup-a-network-install-server</guid>
      <description>How to setup a network install server</description>
      <content:encoded><![CDATA[<p>This howto will describe how to setup Linux network install server. We will be
using <a href="http://en.wikipedia.org/wiki/Preboot_Execution_Environment">pxeboot</a>
and dhcp to allow for bare metal installation without the need for physical
media. Network install servers are essential when large numbers of machines
need to be setup or in cases where machines are frequently setup as well as
for deployment of xen virtual machines.</p>
<p>I have used Centos 5.1 in this howto however i am sure it can be adapted to
work with any other Linux distribution as the concepts remain the same. The
main components that i have used are the following.</p>
<ul>
<li>http server - apache</li>
<li>tftp server</li>
<li>dhcp server - isc dhcp</li>
<li>dns server - isc bind</li>
</ul>
<h2>Installation of software</h2>
<p>I will assume that you already have an installed bare bones Centos 5.1 system
with the hostname server1.example.com. During this howto we will be using the
fictitious domain example.com please substitute with your own domain, and the
192.168.1.0/24 network</p>
<h3>DNS server</h3>
<p>For this how to we will be using a DNS server because our media is stored on a
virtual host, however it is possible to skip DNS setup and just use ip
addresses if the installation servers http server is only going to be used to
serve the media.</p>
<p>Install bind</p>
<pre><code># yum install bind bind-chroot
</code></pre>
<p>Configure bind and add the example.com zone, make the changes below to the file /var/named/chroot/etc/named.conf</p>
<pre><code>options {
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };
};
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view single_view {
        match-clients      { any; };
        match-destinations { any; };
        recursion yes;
        include "/etc/named.rfc1912.zones";

        zone "example.com" {
                type master;
                file "data/example.com.hosts";
        };

        zone "1.168.192.in-addr.arpa" {
                type master;
                file "data/1.168.192.in-addr.arpa.hosts";
        };
};
</code></pre>
<p>Add this to the file /var/named/chroot/var/named/data/example.com.hosts</p>
<pre><code>$ttl 38400
@       IN      SOA     server1.example.com. root.example.com. (
                        2008012900
                        10800
                        3600
                        604800
                        38400 )
@       IN      NS      server1.example.com.
server1 IN A 192.168.1.2
kickstart IN A 192.168.1.2
</code></pre>
<p>Add this to the file /var/named/chroot/var/named/data/1.168.192.in-addr.arpa.hosts</p>
<pre><code>$ttl 38400
@       IN      SOA     server1.example.com. root.example.com. (
                        2008012900
                        10800
                        3600
                        604800
                        38400 )
@       IN      NS      server1.example.com.
2 IN PTR server1.example.com.
</code></pre>
<p>Setup bind to start at boot</p>
<pre><code># chkconfig --level 345 named on
# service named start
</code></pre>
<h3>DHCP server</h3>
<p>We need a dhcp server to allow for pxebooting and automatic assignment of
network parameters.</p>
<p>Install dhcp server</p>
<pre><code># yum install dhcp
</code></pre>
<p>Configure the dhcp server make changes to /etc/dhcpd.conf to look like below</p>
<pre><code>option domain-name-servers 192.168.1.2;
allow booting;
allow bootp;

next-server 192.168.1.2;
filename "pxelinux.0";

subnet 192.168.1.0 netmask 255.255.255.0
{
        range 192.168.1.50 192.168.1.250;
        allow unknown-clients;
        ignore client-updates;
}
</code></pre>
<p>Enable dhcp server to start at boot</p>
<pre><code># chkconfig --level 345 dhcpd on
# service dhcpd start
</code></pre>
<h3>Tftp server</h3>
<p>The tftp server is used to serve the boot images that are required to pxe boot
the machines to be installed.</p>
<p>Install tftp server</p>
<pre><code># yum install tftp-server
</code></pre>
<p>Configure tftp-server to start at boot</p>
<pre><code># chkconfig --level 345 tftp-server on
</code></pre>
<p>Copy syslinux image to tftp server directory</p>
<pre><code># cp /usr/lib/syslinux/pxelinux.0 /tftpboot
</code></pre>
<p>Create pxeboot directory structure</p>
<pre><code># mkdir /tftpboot/{pxelinux.cfg,msgs,os}
</code></pre>
<p>Start tftp server</p>
<pre><code># service xinetd restart
</code></pre>
<h3>Http server</h3>
<p>The http server is used to serve our install tree</p>
<p>Install apache</p>
<pre><code># yum install httpd
</code></pre>
<p>Configure virtual hosts, Since i need to allow for the server to be used for other purposes i am going to setup virtualhosts. The first virtual host is the default virtual host and the second one is the one that will be serving our network install. Edit the file /etc/httpd/conf/httpd.conf and add the following.</p>
<pre><code>NameVirtualHost *:80
&lt;VirtualHost *:80&gt;
   Servername server1.example.com
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
   Servername kickstart.example.com
   DocumentRoot /srv/www
   ErrorLog logs/kickstart.example.com-error_log
   CustomLog logs/kickstart.example.com-access_log common
   &lt;Directory /srv/www/&gt;
   Options +Indexes
   &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</code></pre>
<h2>Setup distributions</h2>
<p>You can setup as many distributions as you want, i will be setting up Centos
to serve as an example on how it is done.</p>
<h3>Centos 5.1</h3>
<p>Create directories to hold the install tree</p>
<pre><code># mkdir -p /srv/www/centos/5.1/os/i386
</code></pre>
<p>Copy files from the DVD or CD's</p>
<pre><code># mount /media/cdrom
# cp /media/cdrom/* /srv/www/centos/5.1/os/i386
</code></pre>
<p>Create the directory to hold pxe boot images</p>
<pre><code># mkdir /tftpboot/os/centos_5.1
</code></pre>
<p>Copy pxeboot images to server</p>
<pre><code># cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /tftpboot/os/centos_5.1
</code></pre>
<p>Create a minimal kickstart to point to http installation, create file /srv/www/centos_5.1.ks and add the following</p>
<pre><code>install
url --url http://kickstart.example.com/centos/5.1/os/i386/
</code></pre>
<p>Add Centos 5.1 to tftpboot menu, edit the file /tftpboot/pxelinux/default and add the following</p>
<pre><code>default centos5.1
prompt 1
timeout 600
display boot.msg

label centos5.1
        kernel os/centos_5.1/vmlinuz
        append ks=http://kickstart.example.com/centos_5.1.ks initrd=os/centos_5.1/initrd.img
</code></pre>]]></content:encoded>
    </item>
  </channel>
</rss>
