<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ajitabh Pandey.Info</title>
	<atom:link href="http://ajitabhpandey.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://ajitabhpandey.info</link>
	<description>My Work, Life, Views and Scriblings</description>
	<lastBuildDate>Sat, 11 Feb 2012 15:54:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>DeleGate &#8211; A Multi-platform, Multi-purpose Proxy Server</title>
		<link>http://ajitabhpandey.info/2011/03/delegate-a-multi-platform-multi-purpose-proxy-server/</link>
		<comments>http://ajitabhpandey.info/2011/03/delegate-a-multi-platform-multi-purpose-proxy-server/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 08:09:04 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[Published Articles]]></category>
		<category><![CDATA[delegate]]></category>
		<category><![CDATA[Proxy]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=392</guid>
		<description><![CDATA[Introduction A proxy server works as an intermediary for requests from clients seeking resources from other servers. There are various types of proxy servers. In this article we will be breifly discussing some of the capabilities of DeleGate. DeleGate is &#8230; <a href="http://ajitabhpandey.info/2011/03/delegate-a-multi-platform-multi-purpose-proxy-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>A proxy server works as an intermediary for requests from clients seeking resources from other servers. There are various types of proxy servers. In this article we will be breifly discussing some of the capabilities of DeleGate.</p>
<p>DeleGate is a multi-platform and multi-purpose general purpose proxy server which runs on Unix, Windows, MacOSX and OS/2. It allows various protocols to pass through it and apply cache and conversion to the pass-through data, access control and routing. Some of the protocols supported by delegate are &#8211; HTTP, FTP, NNTP, SMTP, POP, IMAP, LDAP, Telnet, SOCKS, DNS etc. DeleGate can also translate protocol between clients and server such as converting IPv4and IPv6. Multiple servers can be combined to look as  single server using aliasing and filtering capabilities of DeleGate. For various automated purposes, DeleGate can also be used as an origin server for HTTP, FTP and NNTP.<br />
<span id="more-392"></span></p>
<h2>Configuring DeleGate</h2>
<p>In order to install DeleGate on linux, either the binary can be compiled from source or ready-to-use binaries can be used for 32-bit and 64-bit linux implementations. I could not find a package for DeleGate in Debian, Ubuntu, Fedora or CentOS repositories, so the binary was the only option. Since I had only 64-bit environments at hand, I could only use the 64-bit version of the software. The 64-bit binary worked fine on Fedora 13 and CentOS 5.5, however I could not get it to work on Debian Lenny and Ubuntu. I did not try for too long, but to me it looked like there were some compatibility issues with the binaries. I will leave it to the readers to explore further or compile there own binaries using the source.</p>
<pre class="code"># mkdir -p /opt/delegate/{bin,etc} &amp;&amp; cd /opt/delegate/bin
# wget http://www.delegate.org/anonftp/DeleGate/bin/linux/9.9.7/linux64-dg.gz
# gunzip linux64-dg.gz &amp;&amp; chmod +x linux64-dg.gz
# touch ../etc/dg.conf</pre>
<p>The above commands have just created a directory layout for delegate. Next we need to create a user for running delegate as running it as root is a very very bad idea.</p>
<pre class="code"># useradd -M -c "Delegate Proxy User" -d /opt/delegate delegate
# chown -R delegate:delegate /opt/delegate</pre>
<p>Let us use the /opt/delegate/etc/dg.conf as the configuration file for the delegate. I will discuss one sample configurations &#8211; DeleGate as an HTTP proxy. After you have created the desired configuration, you can start delegate as:</p>
<pre class="code"># su - delegate
$ bin/linux64-dg DGROOT="/opt/delegate" +=etc/dg.conf</pre>
<p>After doing configuration changes, do not forget to reload the latest changes by sending a HUP to the delegate process.</p>
<h2>DeleGate Configuration Options Used</h2>
<p>Following table discusses some of the common configuration options we have used in this article.</p>
<table>
<tbody>
<tr>
<td>-P</td>
<td>-P specifies on which port DeleGate will receive the requests from clients. A host/ip-address can be specified like -Plocalhost:8080 or -P 192.168.1.1:8080. By default the port is a TCP port except if UDP based application protocol is specified in the SERVER=protocol parameter. But still you can still specify -P8080/UDP. You can also specify multiple host:ports where DeleGate will be listening using a comma separated list.</td>
</tr>
<tr>
<td>-T</td>
<td>-T is used to trace system calls. If this option is used then the signals occurring in the DeleGate process will be watched by the parent DeleGate using &#8220;ptrace(2)&#8221;. -Tx here will ensure that the DeleGate processes which are going to execute &#8220;execve(2)&#8221; system call will be trapped and killed. This is a very useful security measure.</td>
</tr>
<tr>
<td>DGROOT</td>
<td>At startup time DeleGate searches for an available DGROOT which is both readable and writable by the user. Typically it will be ${HOME}/delegate and &#8220;/&#8221; if CHROOT is used. This parameter needs to be specified on the command line.</td>
</tr>
<tr>
<td>SERVER</td>
<td>Specifies the protocol to be used for communication with the clients.</td>
</tr>
<tr>
<td>REMITTABLE</td>
<td>Only the listed protocols (to the SERVER) will be permitted to be relayed by the DeleGate proxy. A typical list of protocols which are expected to be relayed through an HTTP proxy are http, https, gopher, ftp, wais.</td>
</tr>
<tr>
<td>CACHE</td>
<td>Specifies if cache is to be used by the proxy or not. A value of &#8216;no&#8217; will disable the cache use and a value of &#8216;do&#8217; will enable the cache and create CACHEDIR if it does not exists.</td>
</tr>
<tr>
<td>TIMEOUT</td>
<td>Specifies timeout period for an action in seconds(by default). A timeout value of &#8220;0&#8243; means &#8220;never timeout&#8221;. The value of timeout can be specified in terms of days, hour and minutes as e.g 1d, 1h, 1m. The action can be, for example, &#8220;shutout&#8221; which specifies that a suspicious client host will be shut out until a relevant file (under ADMDIR/shutout/) is removed or the file is expired by TIMEOUT. This is a good defense against attacks on the proxy.</td>
</tr>
<tr>
<td>MAXIMA</td>
<td>Specifies a maximum number of resource usage, processes, connections etc. &#8220;randstack&#8221; randomizes the range of stack base for security, &#8220;randenv&#8221; randomizes the range of environment variables base and &#8220;randfd&#8221; randomizes range of client socket file-descriptor.</td>
</tr>
<tr>
<td>ADMIN</td>
<td>Specifies the admin contact who will receive emails from DeleGate on various events.</td>
</tr>
<tr>
<td>AUTHORIZER</td>
<td>Specifies the server for authentication and authorization. If specified an access by a client is not permitted without authenticated successfully by the auth-server. We are using the list of usernames and passwords in pairs for authentication. There are various other schemes available for authentication such as PAM.</td>
</tr>
</tbody>
</table>
<h2>DeleGate as HTTP Proxy</h2>
<p>In this sample configuration we have configured DeleGate as an HTTP proxy with authentication and no caching. If you wish caching also, please change the &#8220;CACHE=no&#8221; to &#8220;CACHE=do&#8221;.</p>
<pre class="code"># su - delegate
$ vi /opt/delegate/etc/dg.conf
-P8080
-Tx
DGROOT="/opt/delegate"
SERVER=http
REMITTABLE="http,https/443,gopher,ftp,wais"
CACHE=no
TIMEOUT="shutout:30m"
MAXIMA="randstack:32"
MAXIMA="randenv:1024"
MAXIMA="randfd:32"
ADMIN=tech.support@unixclinic.net
AUTHORIZER="-list{user1:password1,user2:password2}"</pre>
<h2>Moving On</h2>
<p>In this article I have explored on the tip of the iceberg and have only introduced the readers to this marvelous piece of engineering. We have not covered many of the Delegate features such as SOCKS proxy, transparent SOCKS proxy, chaining of proxy etc. Further exploration is left to the readers and I am pretty sure that interested readers will explore and benefit from the capabilities provided by DeleGate.</p>
<p>Interested readers may also want to explore another proxy server &#8211; Dante. I have provided the link in the references section below.</p>
<p>Time permitting I may write in future about implementing other features of DeleGate. Dante is also in my todo list, so watch out.</p>
<h2>References</h2>
<p><a href="http://www.delegate.org/">DeleGate Home Page</a><br />
<a href="http://www.inet.no/dante/index.html">Dante &#8211; A Free SOCKS Proxy Implementation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2011/03/delegate-a-multi-platform-multi-purpose-proxy-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Apache mod_rewrite module on OpenSuSE</title>
		<link>http://ajitabhpandey.info/2010/08/enable-apache-mod_rewrite-module-on-opensuse/</link>
		<comments>http://ajitabhpandey.info/2010/08/enable-apache-mod_rewrite-module-on-opensuse/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 09:13:40 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[Tips/Code Snippets]]></category>
		<category><![CDATA[OpenSuSE]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=384</guid>
		<description><![CDATA[OpenSuSE has mod_rewrite installed, but it is not loaded by default. Check if mod_rewrite is actually loaded by default or not: # grep "^APACHE_MODULES" /etc/sysconfig/apache2 APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config &#8230; <a href="http://ajitabhpandey.info/2010/08/enable-apache-mod_rewrite-module-on-opensuse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>OpenSuSE has mod_rewrite installed, but it is not loaded by default. Check if mod_rewrite is actually loaded by default or not:</p>
<p><code># grep "^APACHE_MODULES" /etc/sysconfig/apache2<br />
APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5"<br />
</code><br />
<span id="more-384"></span><br />
As you can see that &#8220;rewrite&#8221; is not present in the loaded modules. Add &#8220;rewrite&#8221; as below:</p>
<p><code><br />
# vi /etc/sysconfig/apache2<br />
APACHE_MODULES="actions alias auth_basic authn_file authz_host authz_groupfile authz_default authz_user autoindex cgi dir env expires include log_config mime negotiation setenvif ssl userdir php5 rewrite"<br />
# /sbin/service apache2 restart<br />
Syntax OK<br />
Shutting down httpd2 (waiting for all children to terminate)                                          done<br />
Starting httpd2 (prefork)                                                                                        done<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2010/08/enable-apache-mod_rewrite-module-on-opensuse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UW IMAP on OpenSolaris 2009.06</title>
		<link>http://ajitabhpandey.info/2010/07/uw-imap-on-opensolaris-2009-06/</link>
		<comments>http://ajitabhpandey.info/2010/07/uw-imap-on-opensolaris-2009-06/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 10:53:12 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[Solaris/AIX/HP-UX]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[imapd]]></category>
		<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[uw-imap]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=380</guid>
		<description><![CDATA[It is quite surprising that the opensolaris distribution does not come with an imap server in the standard repositories. I needed one and the simplest one to use is the one from UW IMAP. I downloaded the source package from: &#8230; <a href="http://ajitabhpandey.info/2010/07/uw-imap-on-opensolaris-2009-06/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It is quite surprising that the opensolaris distribution does not come with an imap server in the standard repositories. I needed one and the simplest one to use is the one from UW IMAP.</p>
<p>I downloaded the source package from:</p>
<p>ftp://ftp.cac.washington.edu/imap/imap.tar.gz</p>
<p>The UW IMAP documentation is at http://www.washington.edu/imap/documentation/</p>
<p>I have GCC installed in my opensolaris 2009.6<br />
<span id="more-380"></span></p>
<pre class="code">
$ which cc
/usr/gnu/bin/cc
</pre>
<p>I followed the usual compile procedure:</p>
<pre class="code">
$ tar -xvzf imap.tar.gz
$ cd imap-2007e
</pre>
<p>I tried building it, but it failed although GCC is installed. So I thought of compiling it with Sun Studio. I installed the Sun Studio as follows:</p>
<pre class="code">
$ pfexec pkg install developer/sunstudio12u1
</pre>
<p>Next I did some modifications to the src/osdep/unix/Makefile in the UW IMAPD. Following are the lines that need to be changed from the default ones.</p>
<pre class="code">
CC=/usr/bin/cc
SSLCERTS=/etc/openssl/certs
SSLINCLUDE=/usr/include/openssl
SSLLIB=/usr/lib
</pre>
<p>Now run the make command. With UW IMAP you need to tell the system type for which you are building the imap, I tried &#8216;sol&#8217; but it did not work for some reason. Next I tried &#8216;gso&#8217; which is actually for GNU C in solaris, and it worked. Not sure why as I was using the Sun Studio compiler&#8230;.</p>
<pre class="code">
$ make gso
</pre>
<p>Next I needed to manually copy the imapd (I only wanted imapd and not pop as of now).</p>
<pre class="code">
$ pfexec cp imap/imapd /usr/sbin/
</pre>
<p>Now add the inetd service entry</p>
<pre class="code">
imap    stream  tcp     nowait  root    /usr/sbin/imapd     imapd
imaps   stream  tcp     nowait  root    /usr/sbin/imapd     imapd
</pre>
<p>and add it to the SMF framework</p>
<pre class="code">
$ pfexec inetconv
</pre>
<p>I received an error for the imaps entry:</p>
<pre class="code">
inetconv: Error /etc/inet/inetd.conf line 42 invalid or inconsistent fields: service-name protocol
</pre>
<p>Upon checking I found that /etc/services file was missing the entry for the imaps protocol, so I added a line:</p>
<pre class="code">
imaps        993/tcp
</pre>
<p>and imported the services to the SMF again. This was a success this time. Finally we need to enable the daemons, which can be done as follows:</p>
<pre class="code">
$ pfexec svcadm enable svc:/network/imaps/tcp:default
$ pfexec svcadm enable svc:/network/imap/tcp:default
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2010/07/uw-imap-on-opensolaris-2009-06/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is statistics always right, how do you measure the development?</title>
		<link>http://ajitabhpandey.info/2010/04/is-statistics-always-right-how-do-you-measure-the-development/</link>
		<comments>http://ajitabhpandey.info/2010/04/is-statistics-always-right-how-do-you-measure-the-development/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 04:45:38 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/2010/04/is-statistics-always-right-how-do-you-measure-the-development/</guid>
		<description><![CDATA[Sometimes by looking at various statistics being published at various places about India becoming a (so called?) developed country, I am compelled to think that are these statistics reflecting the true Indian progress&#8230;.. For example, according to some reports recently &#8230; <a href="http://ajitabhpandey.info/2010/04/is-statistics-always-right-how-do-you-measure-the-development/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes by looking at various statistics being published at various places about India becoming a (so called?) developed  country, I am compelled to think that are these statistics reflecting the true Indian progress&#8230;..<br />
<span id="more-335"></span><br />
For example, according to some reports recently published some time back, India has around 50 crores of telephones which means one phone per two people. But is it true? Quite a lot of people keep more than one phones, some even has 6-7 phones. According to TRAI (Telecom Regulatory Authority of India) there are 47.1 crores mobile subscribers in the country and 3.7 crore landlines. Does the number of increasing mobiles have anything to do with progress of the country?</p>
<p>The number of people below the line of poverty is still increasing. Villages are getting destroyed  to give way to ever expanding towns and cities. In the name of SEZ (Special Economic Zone) furtile agriculture land is being destroyed. If all agricultural land will be turned in to industrial lands, where will we grow food which we all eat. </p>
<p>This is not development, but destruction. Its high time that we educated Indians start raising these issues and concerns and educate the general public about this. </p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2010/04/is-statistics-always-right-how-do-you-measure-the-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On Sabayon 5 now</title>
		<link>http://ajitabhpandey.info/2010/04/on-sabayon-5-now/</link>
		<comments>http://ajitabhpandey.info/2010/04/on-sabayon-5-now/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 14:49:59 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[Sabayon]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=333</guid>
		<description><![CDATA[Last night installed Sabayon 5 amd64 on my laptop. All went fine except when I tried to do an update. I did the following as suggested in the Sabayon wiki: $ sudo equo update $ sudo equo update --force $ &#8230; <a href="http://ajitabhpandey.info/2010/04/on-sabayon-5-now/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last night installed Sabayon 5 amd64 on my laptop. All went fine except when I tried to do an update. I did the following as suggested in the Sabayon wiki:<br />
<span id="more-333"></span></p>
<pre class="code">
$ sudo equo update
$ sudo equo update --force
$ sudo equo upgrade --ask
</pre>
<p>I was shown a long list of around 700+ packages which I started updating. After I was done, I executed the following and rebooted afterwards.</p>
<pre class="code">
$ sudo equo conf update
</pre>
<p>Upon logging in to the newly updated system, I was surprised with &#8216;wicd&#8217; asking me for a root password and then stating that its having a DBus error. So I connected the ethernet cable and a bit of search on the net (using Yahoo search engine) pointed me that I need to add wicd to startup at boot, which I achieved using the following:</p>
<pre class="code">
$ sudo rc-update add wicd boot
</pre>
<p>I next rebooted, but still no joy. I was this time getting a message &#8220;BAD PASSWORD&#8221;. I was pretty sure that my password was correct. Again I spent some time on searching the internet using ethernet cable and finally found that a new version of knetworkmanager was in the entropy, so I decided to switch to it and remove the wicd. </p>
<pre class="code">
$ sudo equo remove wicd
$ sudo equo install knetworkmanager
</pre>
<p>This was smooth and all started working well.</p>
<p>This does not mean that there is a problem with wicd. There are lots of people who had problem with knetworkmanager and have switched to wicd. This is the prime reason that sabayon guys have perhaps included wicd into the distribution. But the point which I am not able to understand is that why they changed my functional knetworkmanager during update to wicd? </p>
<p>Anyways, all izz well that ends well. I am writing this post from wire. </p>
<p>Oh!! and I have not rebooted yet. Ok let me reboot after this post and see if all remains well or not. Obviously you will see something either here or on twitter if all is not well. <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2010/04/on-sabayon-5-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Filesystem Quota in linux</title>
		<link>http://ajitabhpandey.info/2010/01/setting-filesystem-quota-in-linux/</link>
		<comments>http://ajitabhpandey.info/2010/01/setting-filesystem-quota-in-linux/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 06:45:16 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Quota]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/2010/01/setting-filesystem-quota-centos/</guid>
		<description><![CDATA[I recently activated quota on my slicehost slice and it was quite simple and fast to do. The only disadvantage is that I needed to set quota on the only filesystem I had, which is /. If there is a &#8230; <a href="http://ajitabhpandey.info/2010/01/setting-filesystem-quota-in-linux/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently activated quota on my slicehost slice and it was quite simple and fast to do. The only disadvantage is that I needed to set quota on the only filesystem I had, which is /. If there is a choice then it is advisable to set quota on non-root filesystem such as /home, /var etc. The primary reason for this is that while performing the quota check the filesystem needs to be mounted read-only temporarily by the quotacheck utility. Since the root filesystem can not be mounted read-only while the system is running we need to do a force quota check on the system which might result in in-accurate figures and can cause corruption to the quota files.<br />
<span id="more-327"></span><br />
Here are the commands which I executed in quick succession to enable the quota:</p>
<pre class="code">
$ sudo modprobe quota_v2
$ sudo lsmod|grep quota
quota_v2               11392  0
$ sudo mount -o remount,noatime,usrquota,grpquota /
</pre>
<p>The following command will create the quota files and the -m option is to force the execution as the filesystem can not be mounted read-only.</p>
<pre class="code">
$ sudo quotacheck -cugm /
</pre>
<p>Now to calculate the current usage,</p>
<pre class="code">
$ sudo quotacheck -avugm
quotacheck: Scanning /dev/sda1 [/] done
quotacheck: Checked 8990 directories and 87482 files
</pre>
<p>Now to set the quota for user testuser we can use setquota. Following command set the quota to 1GB.</p>
<pre class="code">
$ sudo setquota -u testuser 1000000 1048576 0 0 -a
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2010/01/setting-filesystem-quota-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Until We Meet Again</title>
		<link>http://ajitabhpandey.info/2009/12/until-we-meet-again/</link>
		<comments>http://ajitabhpandey.info/2009/12/until-we-meet-again/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 10:42:55 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Work Life]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/2009/12/until-we-meet-again/</guid>
		<description><![CDATA[To My Colleagues / Friends at ITC / BGI / Blackrock Today (16th Dec 2009) is my last day at ITC Infotech as I have decided to explore opportunities elsewhere in India. I would like to take this opportunity to &#8230; <a href="http://ajitabhpandey.info/2009/12/until-we-meet-again/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #339966;"><strong>To My Colleagues / Friends at ITC / BGI / Blackrock</strong></span></p>
<p><span style="color: #339966;">Today (16th Dec 2009) is my last day at ITC Infotech as I have decided to explore opportunities elsewhere in India. I would like to take this opportunity to thank you all and let you know that I have enjoyed working with you over the past almost three years and am greatful for the opportunity to work with you.</span><br />
<span id="more-322"></span><br />
<span style="color: #339966;">Please keep in touch through major neteworking sites such as Orkut, Facebook and LinkedIn. You can also Follow me on Twitter</span></p>
<p><span style="color: #339966;">फिर मिलेंगे (Phir Milenge) | До свидаìния (Do Svidanya) | See You</span></p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2009/12/until-we-meet-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating VPNs with OpenVPN</title>
		<link>http://ajitabhpandey.info/2009/10/creating-vpns-with-openvpn/</link>
		<comments>http://ajitabhpandey.info/2009/10/creating-vpns-with-openvpn/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 23:33:47 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[Published Articles]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=302</guid>
		<description><![CDATA[Introduction A VPN is a set of tools which allow networks at different locations to be securely connected, using a public network as the transport layer. A VPN produces a virtual &#8220;dedicated circuit&#8221; over the internet and use cryptography to &#8230; <a href="http://ajitabhpandey.info/2009/10/creating-vpns-with-openvpn/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>A VPN is a set of tools which allow networks at different locations to be securely connected, using a public network as the transport layer. A VPN produces a virtual &#8220;dedicated circuit&#8221; over the internet and use cryptography to secure it.<br />
<span id="more-302"></span><br />
A SSL VPN uses industry standard SSL and runs in user space, simplifying administration and implementation. The SSL VPN is just a web application that tries to give users the services they need without a full VPN implementation. </p>
<p>OpenVPN is an opensource SSL VPN solution targeted for SMEs and enterprises. Wide range of configurations exists for openvpn including site-to-site VPNs, remote access, Wi-Fi security etc. It uses the <code>tun</code> interface for virtual linking of the two end points of the VPN. A <code>tun</code> interface is a virtual network adapter that looks like point-to-point network hardware to the OS. But since its virtual, the data is actually pushed to the user space program which can then open a tun device like a file and read and write IP packets from and to it. </p>
<p>NOTE &#8211; A tap interface is similar to the tun except that it emulates ethernet rather than point-to-point.</p>
<p>In a user space VPN the IP packets from a tuntap adapter are encrypted and then encapsulated into UDP and sent over the internet. At the destination the remote host deencapsulates the IP packet, decrypts and authenticates before pumping it into a tun/tap virtual adapter.</p>
<h2>Configuring OpenVPN</h2>
<p>There are various ways to configure OpenVPN and you can choose the one matching your requirement. In this article we will see a few types of configurations which are typically used. </p>
<p>To start, install openvpn as follows. The server setup in this article has always used a linux system and various clients have been used for testing like windows-xp with openvpn-gui, fedora and ubuntu with network-manager openvpn plugin, debian, centos and fedora with openvpn client through command line.</p>
<p>We will start with installing openvpn from the distributions repository.</p>
<p>On CentOS 5.3 I had activated the Fedora EPEL repository for OpenVPN package to make sure that I use a 2.1 version build.</p>
<pre class="code">$ sudo yum install openvpn</pre>
<p>The configuration files are kept in the <code>/etc/openvpn</code> directory. The init script installed with the package takes care of registering the openvpn with the <code>chkconfig</code> system, so that it can be stared and stopped using the service command. While starting the openvpn service, the init script takes care of loading all the configuration files from <code>/etc/openvpn</code> directory with <code>.conf</code> extension. If for a particular configuration some initialization is to be done then a script can be created in <code>/etc/openvpn</code> directory by the same name as the configuration file with <code>.sh</code> extension. So, for example our configuration file is called <code>/etc/openvpn/server.conf </code>a script <code>/etc/openvpn/server.sh</code> can be created which will be executed before loading the configuration from <code>server.conf</code> file.</p>
<p>We will use the following directory structure for our setup so let us create it:</p>
<pre class="code">$ sudo mkdir /etc/openvpn/keys</pre>
<p>Regardless of the configuration chosen, there are few options which are used in all types of configurations. Although some of these are default settings, still it is a good idea to specify them in the configuration file. In the following example, the static key configuration is the most basic configuration, so I will describe all basic configurations there and from there on for other configurations just the additions and removals will be specified. Initially we are only allowing the client and server to ping each other. After reviewing all<br />
popular configurations we will have a look at how to provide the clients access to the private network behind the VPN and also to configure a proxy to let the clients surf the net securely.</p>
<p>NOTE &#8211; On the CentOS Server SELINUX was enabled so the server set-up described works on the SELINUX enabled boxes. At places I have shown the output displaying the SELINUX contexts.</p>
<h2>Static Key Configuration</h2>
<p>The static key configuration of openvpn is the most basic one and only allows one client to connect to one server. This simple setup can be used by you if you want to setup a VPN connectivity between your laptop or home computer and one of your servers on the internet somewhere. This is the quickest configuration to setup. However, we need to make sure that after the key is generated at one end, it is securely transferred to the other end before initiating the connection. This is only a one time job, so the pain is<br />
worth the simplicity. </p>
<p>To start we will generate the static key as</p>
<pre class="code">
root@vpn.unixclinic.net # cd /etc/openvpn/keys
root@vpn.unixclinic.net # /usr/sbin/openvpn --genkey --secret static.key
root@vpn.unixclinic.net # ls -lZ
-rw------- root root user_u:object_r:openvpn_etc_rw_t static.key
</pre>
<p>Now let us configure the server part:</p>
<pre class="code">
root@vpn.unixclinic.net # vi /etc/openvpn/static-server.conf
port 1194
proto udp
dev tun
# The keep alive directive is particularly important if you are using UDP
# through a stateful firewall like Netfilter. Because UDP is connectionless
# any stateful firewall will forget about the connection if packets are not
# going through it at regular intervals.
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
# Enable compression (use only if compiled with lzo support)
comp-lzo
# Short log of active connections and internal routing table.
# Recreated every minute.
status openvpn-status.log
log-append openvpn.log
# Verbosity level in the log (0=silent, 3 or 4=normal, 9=maximum for
debugging)
verb 3
### Change following for different configurations
# For Static key server configuration
ifconfig 10.8.0.1 10.8.0.2
secret /etc/openvpn/keys/static.key
</pre>
<p>At the client side the configuration file will look like below. As you can see that there is only one line which is majorly different and that is the <code>ifconfig</code> line, where the IP addresses are reversed. Also there is a configuration option <code>remote</code> at the client side. The purpose of this option is to specify the openvpn server to which this client has to connect to. The <code>remote</code> option can take both the IP address and resolvable hostname. Please note that you need to find a pre-existing secure channel for the static key to be<br />
transferred to the client from the server.</p>
<pre class="code">
root@client # vi /etc/openvpn/static-client.conf
port 1194
proto udp
dev tun
# The keep alive directive is particularly important if you are using UDP
# through a stateful firewall like Netfilter. Because UDP is connectionless
# any stateful firewall will forget about the connection if packets are not
# going through it at regular intervals.
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
# Enable compression (use only if compiled with lzo support)
comp-lzo
# Short log of active connections and internal routing table.
# Recreated every minute.
status openvpn-status.log
log-append openvpn.log
# Verbosity level in the log (0=silent, 3 or 4=normal, 9=maximum for
debugging)
verb 3
# Remote OpenVPN server to connect to
remote vpn.unixclinic.net
### Change following for different configurations
# For Static key client configuration
ifconfig 10.8.0.2 10.8.0.1
secret /etc/openvpn/keys/static.key
</pre>
<p>Now start the openvpn server at both the ends and tail the log files at both ends for any messages.</p>
<pre class="code">
root@vpn.unixclinic.net # tail -50 /etc/openvpn/openvpn.log
Thu Jun 18 03:16:04 2009 OpenVPN 2.1_rc15 x86_64-redhat-linux-gnu [SSL] [LZO2] [EPOLL] built on Nov 30 2008
Thu Jun 18 03:16:04 2009 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Thu Jun 18 03:16:04 2009 Static Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Jun 18 03:16:04 2009 Static Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jun 18 03:16:04 2009 Static Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Jun 18 03:16:04 2009 Static Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jun 18 03:16:04 2009 LZO compression initialized
Thu Jun 18 03:16:04 2009 TUN/TAP device tun0 opened
Thu Jun 18 03:16:04 2009 TUN/TAP TX queue length set to 100
Thu Jun 18 03:16:04 2009 /sbin/ip link set dev tun0 up mtu 1500
Thu Jun 18 03:16:04 2009 /sbin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2
Thu Jun 18 03:16:04 2009 Data Channel MTU parms [ L:1545 D:1450 EF:45 EB:135 ET:0 EL:0 AF:3/1 ]
Thu Jun 18 03:16:04 2009 Local Options hash (VER=V4): '4b91e501'
Thu Jun 18 03:16:04 2009 Expected Remote Options hash (VER=V4): '48593abd'
Thu Jun 18 03:16:04 2009 Socket Buffers: R=[124928->131072] S=[124928->131072]
Thu Jun 18 03:16:04 2009 UDPv4 link local (bound): [undef]:1194
Thu Jun 18 03:16:04 2009 UDPv4 link remote: [undef]
Thu Jun 18 03:16:09 2009 Peer Connection Initiated with 116.87.186.181:1194
Thu Jun 18 03:16:10 2009 Initialization Sequence Completed
Thu Jun 18 03:18:46 2009 write UDPv4 [EHOSTUNREACH]: Operation not permitted (code=1)

root@client # tail -50 /etc/openvpn/openvpn.log
Thu Jun 18 15:16:08 2009 OpenVPN 2.1_rc15 x86_64-redhat-linux-gnu [SSL] [LZO2] [EPOLL] built on Nov 30 2008
Thu Jun 18 15:16:08 2009 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Thu Jun 18 15:16:08 2009 Static Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Jun 18 15:16:08 2009 Static Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jun 18 15:16:08 2009 Static Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Jun 18 15:16:08 2009 Static Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Jun 18 15:16:08 2009 LZO compression initialized
Thu Jun 18 15:16:08 2009 TUN/TAP device tun0 opened
Thu Jun 18 15:16:08 2009 TUN/TAP TX queue length set to 100
Thu Jun 18 15:16:08 2009 /sbin/ip link set dev tun0 up mtu 1500
Thu Jun 18 15:16:08 2009 /sbin/ip addr add dev tun0 local 10.8.0.2 peer 10.8.0.1
Thu Jun 18 15:16:08 2009 Data Channel MTU parms [ L:1545 D:1450 EF:45 EB:135 ET:0 EL:0 AF:3/1 ]
Thu Jun 18 15:16:08 2009 Local Options hash (VER=V4): '48593abd'
Thu Jun 18 15:16:08 2009 Expected Remote Options hash (VER=V4): '4b91e501'
Thu Jun 18 15:16:08 2009 Socket Buffers: R=[124928->131072] S=[124928->131072]
Thu Jun 18 15:16:08 2009 UDPv4 link local (bound): [undef]:1194
Thu Jun 18 15:16:08 2009 UDPv4 link remote: 173.45.227.64:1194
Thu Jun 18 15:16:14 2009 Peer Connection Initiated with 173.45.227.64:1194
Thu Jun 18 15:16:14 2009 Initialization Sequence Completed
</pre>
<p>Now you can ping the client from server and server from client.</p>
<pre class="code">
root@vpn.unixclinic.net # ping -c2 10.8.0.2
PING 10.8.0.2 (10.8.0.2) 56(84) bytes of data.
64 bytes from 10.8.0.2: icmp_seq=1 ttl=64 time=256 ms
64 bytes from 10.8.0.2: icmp_seq=2 ttl=64 time=256 ms

root@client # ping -c2 10.8.0.1
PING 10.8.0.1 (10.8.0.1) 56(84) bytes of data.
64 bytes from 10.8.0.1: icmp_seq=1 ttl=64 time=256 ms
64 bytes from 10.8.0.1: icmp_seq=2 ttl=64 time=255 ms
</pre>
<p>This completes our static key based setup. Let us now move on to certificate based authentication.</p>
<h2>Certificate Based Authentication</h2>
<p>The static key based setup we saw above will limit us to one client connecting to one server and also does not provide enough security. OpenVPN&#8217;s support for PKI (Public Key Infrastructure) allows multiple clients to connect to the open vpn server securely. The number of clients is only limited by the available bandwidth and the hardware resources available with the openvpn server.</p>
<p>If you are setting the OpenVPN for your corporate use then you may want to use a comercial CA for issuance of certificates. However, if you want to avoid that additional cost, you can create your own CA for your internal use.</p>
<p>For those who just want to setup a quick PKI for use by OpenVPN only or for laboratory testing of the concept before rolling out the production setup openvpn bundles a set of scripts and tools called easy-rsa. You will get easy-rsa from any OpenVPN version downloaded from the main website. If you have installed the packaged openvpn from your distribution, you should find this typically at <code>/usr/share/doc/openvpn/examples/easy-rsa</code> in Debian and <code>/usr/share/openvpn/easy-rsa</code> in CentOS. Please feel free to copy this directory to a convenient location of your choice. I typically put this in <code>/opt/openvpneasy-rsa-2.0</code> directory and put that in my path, so I will assume that is the case here:</p>
<pre class="code">
root@vpn.unixclinic.net # mkdir -p /opt/easy-rsa/keys
</pre>
<p>If you have a CentOS server then copy as follows:</p>
<pre class="code">
root@vpn.unixclinic.net # cp -r /usr/share/openvpn/easy-rsa/2.0/* /opt/easy-rsa/
</pre>
<p>On a Debian server copy the easy-rsa as follows:</p>
<pre class="code">
root@vpn.unixclinic.net # cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /opt/easy-rsa/
</pre>
<p>Next put the directory in your path for easier working with easy-rsa.</p>
<pre class="code">
root@vpn.unixclinic.net # export PATH=$PATH:/opt/easy-rsa
</pre>
<p>The file <code>/opt/easy-rsa/vars</code> contains the required environment variables for generating the keys. This file is very-well commented and hence I would not be describing this here. Most of the variable can be left to their default values. Make sure you change the <code>EASY_RSA</code> variable to the directory where the <code>easy-rsa</code> tools are copied. The default value may not suit our requirements:</p>
<pre class="code">
export EASY_RSA="/opt/easy-rsa"
</pre>
<p>You may want to change the following variables. Following, are the values for these variables which are used for the purpose of this article:</p>
<pre class="code">
export KEY_COUNTRY="IN"
export KEY_PROVINCE="UA"
export KEY_CITY="Nainital"
export KEY_ORG="Unixclinic"
export KEY_EMAIL="casupport@unixclinic.net"
</pre>
<p><strong>NOTE -</strong> By default the root CA key and certificates expiry is set to 3650 days (10 years). Practically the certificates should expire typically after one year or two years. So I additionally changed the KEY_EXPIRE to 365 days. </p>
<p>Now let us start generating the necessary keys and certificates. To start with we need to source the variables specified in vars file and make sure that existing keys directory is cleaned. Pay extra attention to the &#8216;.&#8217; in the following command. This &#8216;.&#8217; will make sure that the environment variables will be setup in the current shell.</p>
<pre class="code">
root@vpn.unixclinic.net # . vars
NOTE: If you run ./clean-all, I will be doing a rm -rf on /opt/easy-rsa/keys
root@vpn.unixclinic.net # clean-all
</pre>
<p>Next we need to build the Diffie-Hellman (DH) parameters. It took me less than a min to generate a 1024 bit long safe prime on my server. Might take longer on your machine. I have snipped the output.</p>
<pre class="code">
root@vpn.unixclinic.net # build-dh
Generating DH parameters, 1024 bit long safe prime, generator 2
This is going to take a long time
................................................+

.... [snipped..]
</pre>
<p>Next we will generate the root CA certificate and key:</p>
<pre class="code">
root@vpn.unixclinic.net # build-ca
Generating a 1024 bit RSA private key
.++++++
..++++++
writing new private key to 'ca.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [IN]:
State or Province Name (full name) [UA]:
Locality Name (eg, city) [Nainital]:
Organization Name (eg, company) [Unixclinic]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [Unixclinic CA]:unixclinic.net
Name []:Unixclinic CA
Email Address [casupport@unixclinic.net]:
</pre>
<p>Now that our CA has been setup, we need to create a certificate for our VPN server. This can be done as follows:</p>
<pre class="code">
root@vpn.unixclinic.net # build-key-server vpn.unixclinic.net
Generating a 1024 bit RSA private key
....++++++
..++++++
writing new private key to 'vpn.unixclinic.net.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [IN]:
State or Province Name (full name) [UA]:
Locality Name (eg, city) [Nainital]:
Organization Name (eg, company) [Unixclinic]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [vpn.unixclinic.net]:
Name []:OpenVPN Server
Email Address [casupport@unixclinic.net]:vpnsupport@unixclinic.net

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:password
An optional company name []:Unixclinic
Using configuration from /opt/easy-rsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'IN'
stateOrProvinceName   <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'UA'
localityName          <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'Nainital'
organizationName      <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'Unixclinic'
commonName            <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'vpn.unixclinic.net'
name                  <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'OpenVPN Server'
emailAddress          :IA5STRING:'vpnsupport@unixclinic.net'
Certificate is to be certified until Jun 22 04:24:13 2010 GMT (365 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
</pre>
<p>Now we will have to copy the server certificate to the <code>/etc/openvpn/keys</code> directory and make sure that the private key has the most restrictive permissions:</p>
<pre class="code">
root@vpn.unixclinic.net # cp -v /opt/easy-rsa/keys/vpn.unixclinic.net.{crt,key} /opt/easy-rsa/keys/dh1024.pem /etc/openvpn/keys/
'/opt/easy-rsa/keys/vpn.unixclinic.net.crt' -> '/etc/openvpn/keys/vpn.unixclinic.net.crt'
'/opt/easy-rsa/keys/vpn.unixclinic.net.key' -> '/etc/openvpn/keys/vpn.unixclinic.net.key'
'/opt/easy-rsa/keys/dh1024.pem' -> '/etc/openvpn/keys/dh1024.pem'

root@vpn.unixclinic.net # cp -v /opt/easy-rsa/keys/ca.crt /etc/openvpn/keys/

'/opt/easy-rsa/keys/ca.crt' -> '/etc/openvpn/keys/ca.crt'

root@vpn.unixclinic.net # chmod 0600 /etc/openvpn/keys/vpn.unixclinic.net.key
</pre>
<p>Now let us  configure the server configuration file, I will call this <code>keyauth-server.conf</code>. Copy the contents till the line which states &#8220;Change following for different configurations&#8221;. Add the following lines to the configuration:</p>
<pre class="code">
##### PKI authentication

dh /etc/openvpn/keys/dh1024.pem

ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/vpn.unixclinic.net.crt

# The following file should be kept very secret.
key /etc/openvpn/keys/vpn.unixclinic.net.key

# Specifies the range of IP addresses allocated by server to client.
# The server itself will take 10.8.0.1 as its IP address.
server 10.8.0.0 255.255.255.0

# Makes sure that if available the client always gets the previous IP address.
# The record of IP addresses allocated to client is in ipp.txt file.
ifconfig-pool-persist ipp.txt

# Maximum number of clients which can connect, default is 100.
max-clients 10
</pre>
<p>Now we need to generate the client certificate as follows:</p>
<pre class="code">
root@vpn.unixclinic.net # ./build-key ajitabh
Generating a 1024 bit RSA private key
...++++++
........++++++
writing new private key to 'ajitabh.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [IN]:
Stapte or Province Name (full name) [UA]:
Locality Name (eg, city) [Nainital]:
Organization Name (eg, company) [Unixclinic]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [ajitabh]:
Name []:Ajitabh Pandey
Email Address [casupport@unixclinic.net]:ajitabhp@unixclinic.net

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:password
An optional company name []:
Using configuration from /opt/easy-rsa/openssl.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'IN'
stateOrProvinceName   <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'UA'
localityName          <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'Nainital'
organizationName      <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'Unixclinic'
commonName            <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'ajitabh'
name                  <img src='http://ajitabhpandey.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> RINTABLE:'Ajitabh Pandey'
emailAddress          :IA5STRING:'ajitabhp@unixclinic.net'
Certificate is to be certified until Jun 23 04:38:27 2010 GMT (365 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
</pre>
<p>While creating the client certificate, pay special attention to the CN (Common Name), it should be unique as well as easily identifiable just in case you decide to do the client specific configuration later on. Also try not to put blank space in the CN. After the client key is created transfer the .crt, .key and ca.crt files securely to the client using some pre-exsiting secure channel. I typically consider SCP/SFTP to be pretty safe. You can use USB thumbdrives to transfer the client certificate. <strong>Please note that the OpenVPN server does not need to know anything about the client certificates. So feel free to generate the client certificates on a seperate machine but make sure that they are signed by the same CA using which the server&#8217;s keys are signed. I used the same machine to generate the client certificate.</strong></p>
<p>If you are using OpenVPN client then add the following in the configuration for PKI authentication:</p>
<pre class="code">
## PKI Authentication
# Tell the OpenVPN that we are client.
# This will be use full to pull configuration settings from server later on.
client
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/ajitabh.crt
key /etc/openvpn/keys/ajitabh.key
</pre>
<p>Start the OpenVPN server and client and they should connect. Check out which IP address has been allocated by the server to the client before pinging. The server does not allocate the IP addresses in a sequence.</p>
<h2>Using IPTABLES For Simple Internal Network Access</h2>
<p>In the multi-client setup often you may require to provide protected network access to the VPN clients connecting to the server. There are two ways of doing this:</p>
<ul>
<li>Configure the default router of your organisation to send all traffic destined for VPN addresses (10.8.0.0/24 in our case) to the VPN server.</li>
<li>Masquerade all the VPN traffic to originate from the VPN server internal IP address (not the 10.8.0.1)</li>
</ul>
<p>In most of the case my clients have chosen to go for masquerading as they host their server in external data centre and do not have control of the router. This can be done as follows:</p>
<pre class="code">
root@vpn.unixclinic.net # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
</pre>
<p>I am assuming that the VPN server is connected to the internal network through eth0 interface</p>
<p>Further one of my clients posed the requirement of forcing all port 80 traffic coming from the VPN clients to go through their squid proxy. This can be achieved by following simple iptables rule:</p>
<pre class="code">
root@vpn.unixclinic.net # iptables -t nat -A PREROUTING -i tun+ -p tcp --dport 80 -j REDIRECT --to-port 3128
</pre>
<h2>Moving On</h2>
<p>In this article we have seen two of the very commonly used configurations for OpenVPN. I have used OpenVPN with various types of configurations such as authentications using a MySQL database, freeradius backends, pam etc. If time permits I will try to cover these configurations in some future article.</p>
<h2>References</h2>
<p><a href="http://www.openvpn.net/index.php/open-source/documentation.html">OpenVPN Documentation</a><br />
<a href="http://openvpn.org/index.php/open-source/faq.html">OpenVPN FAQ</a><br />
<a href="http://openvpn.org/index.php/open-source/articles.html">OpenVPN Articles</a><br />
<a href="http://openvpn.net/papers/BLUG-talk/index.html">The user-space VPN and OpenVPN</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2009/10/creating-vpns-with-openvpn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade to php5 in CentOS 4</title>
		<link>http://ajitabhpandey.info/2009/08/upgrade-to-php5-in-centos-4/</link>
		<comments>http://ajitabhpandey.info/2009/08/upgrade-to-php5-in-centos-4/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 10:55:54 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=305</guid>
		<description><![CDATA[Recently one of my clients requested that he needs php5 on one of his production servers. The server runs CentOS 4.7 x86_64. I had recently migrated this server from RHEL 4.7 (see Migrating RHEL 4.6 to CentOS 4.6). PHP5 is &#8230; <a href="http://ajitabhpandey.info/2009/08/upgrade-to-php5-in-centos-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently one of my clients requested that he needs php5 on one of his production servers. The server runs CentOS 4.7 x86_64. I had recently migrated this server from RHEL 4.7 (see <a title="Migrating RHEL 4.7 to CentOS 4.7" href="http://ajitabhpandey.info/2009/06/migrating-rhel-4-to-centos/">Migrating RHEL 4.6 to CentOS 4.6</a>).<br />
<span id="more-305"></span><br />
PHP5 is present in the CentOSPlus repository. Since I had yum-priorities plugin installed and specified the priority of 2 for the CentOSPlus repository, the package just can not be installed like that. At this moment I took the opportunity of installing the entire webstack from the CentOSPlus repository.</p>
<p>Following is my repository configuration specified in <code>/etc/yum.repos.d/CentOS-Base.repo</code>. The <code>exclude</code> line in the <code>base</code> and <code>update</code> repositories exclude the web stack packages from these repositories as we will be taking them from the CentOSPlus repository.</p>
<pre class="code"># cat /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
exclude=php* httpd* postgres* MySQL* mysql* perl perl-DBD-MySQL perl-DBD-Pg perl-DBI perl-suidperl unixODBC* mod_auth_mysql mod_auth_pgsql mod_perl mod_perl-devel mod_ssl
priority=1
protect=1

#released updates
[update]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
exclude=php* httpd* postgres* MySQL* mysql* perl perl-DBD-MySQL perl-DBD-Pg perl-DBI perl-suidperl unixODBC* mod_auth_mysql mod_auth_pgsql mod_perl mod_perl-devel mod_ssl
priority=1
protect=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1
protect=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=1
protect=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=2
protect=1

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&amp;arch=$basearch&amp;repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
priority=2
protect=1</pre>
<p>After this, when I did tried to upgrade php to php5 as:</p>
<pre class="code"># yum --enablerepo=centosplus update php</pre>
<p>I received some transaction check errors as shown below:</p>
<pre class="code">Transaction Check Error:   file /etc/my.cnf from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/README from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/armscii8.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/ascii.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp1251.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp1256.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp1257.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp850.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp852.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/cp866.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/dec8.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/geostd8.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/greek.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/hebrew.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/hp8.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/keybcs2.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/koi8r.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/koi8u.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/latin1.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/latin2.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/latin5.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/latin7.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/macce.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/macroman.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/charsets/swe7.xml from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4
  file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.0.68-1.el4_6 conflicts with file from package mysql-4.1.22-2.el4</pre>
<p>So I decided to update the <code>mysql</code> also. and the following worked:</p>
<pre class="code"># yum --enablerepo=centosplus update php mysql</pre>
<p>Later on I upgraded the other critical component <code>httpd</code> also as follows:</p>
<pre class="code"># yum --enablerepo=centosplus update httpd</pre>
<h2>References</h2>
<p><a href="http://mirror.centos.org/centos/4/centosplus/Readme.txt" target="_blank">CentOSPlus Readme for CentOS 4</a><br />
<a href="http://wiki.centos.org/AdditionalResources/Repositories/CentOSPlus/CentOSWebStack" target="_blank">CentOS Web Stack for CentOS 4</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2009/08/upgrade-to-php5-in-centos-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Locale Problems in Debian  and Ubuntu</title>
		<link>http://ajitabhpandey.info/2009/07/locale-problems-in-debian-and-ubuntu/</link>
		<comments>http://ajitabhpandey.info/2009/07/locale-problems-in-debian-and-ubuntu/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 10:49:11 +0000</pubDate>
		<dc:creator>Ajitabh</dc:creator>
				<category><![CDATA[FLOSS]]></category>
		<category><![CDATA[Tips/Code Snippets]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Locale]]></category>

		<guid isPermaLink="false">http://ajitabhpandey.info/?p=293</guid>
		<description><![CDATA[Recently I have been facing some issues with locales in Debian and Ubuntu based Xen based virtual servers. These typically appear while running the man command and apt-get or dpkg commands. The message typically are of the kinds: perl: warning: &#8230; <a href="http://ajitabhpandey.info/2009/07/locale-problems-in-debian-and-ubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I have been facing some issues with locales in Debian and Ubuntu based Xen based virtual servers. These typically appear while running the <code>man</code> command and <code>apt-get</code> or <code>dpkg</code> commands.<br />
<span id="more-293"></span><br />
The message typically are of the kinds:</p>
<pre class="code">
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
</pre>
<p>The solution for this was simple:</p>
<pre class="code">
$ sudo apt-get install locales
$ sudo dpkg-reconfigure locales
</pre>
<p>In a more recent experience on one of the Ubuntu Jaunty (9.04) builds, while I ran the above <code>dpkg-reconfigure</code> command the error messages were:</p>
<pre class="code">
$ sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_US:en",
	LC_ALL = (unset),
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
</pre>
<p>In order to fix them, see below:</p>
<pre class="code">
$ sudo locale-gen en_US.UTF-8
Generating locales...
  en_US.UTF-8... up-to-date
Generation complete.
$ sudo /usr/sbin/update-locale LANG=en_US.UTF-8
</pre>
<p>For the time being these should be enough to solve your problems. If time permits perhaps I will write in detail about how these locales work and what all basic utilities deal with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://ajitabhpandey.info/2009/07/locale-problems-in-debian-and-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
