<?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>Linux Explore &#187; IPSec</title>
	<atom:link href="https://blog.linuxexplore.com/tag/ipsec/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.linuxexplore.com</link>
	<description>Exploring Linux</description>
	<lastBuildDate>Mon, 07 Apr 2014 00:30:50 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>IPSec Communication  for VPN Setup in CentOS 6 / RHEL 6.3</title>
		<link>https://blog.linuxexplore.com/2013/04/07/ipsec-communication-for-vpn-setup-in-centos-6-rhel-6-3/</link>
		<comments>https://blog.linuxexplore.com/2013/04/07/ipsec-communication-for-vpn-setup-in-centos-6-rhel-6-3/#comments</comments>
		<pubDate>Sat, 06 Apr 2013 19:21:09 +0000</pubDate>
		<dc:creator><![CDATA[linuxexplore]]></dc:creator>
				<category><![CDATA[Linux Explore How to]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[IPSec]]></category>
		<category><![CDATA[IPSec VPN]]></category>
		<category><![CDATA[ipsec-tools]]></category>
		<category><![CDATA[L2TP VPN]]></category>
		<category><![CDATA[Linux Security]]></category>
		<category><![CDATA[PSK]]></category>
		<category><![CDATA[racoon]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://linuxexplore.com/?p=724</guid>
		<description><![CDATA[The use of IPSEC transport mode for server to server communication is one of the best solutions to provide authentication, integrity, access control, and confidentiality. IPSEC is built into to the Linux kernel, in other words there is no daemon running in the background. IPSEC does not require port-forwarding; some people elect to use SSH,&#8230;]]></description>
				<content:encoded><![CDATA[<p>The use of <strong>IPSEC</strong> transport mode for server to server communication is one of the best solutions to provide authentication, integrity, access control, and confidentiality. IPSEC is built into to the Linux kernel, in other words there is no daemon running in the background. IPSEC does not require port-forwarding; some people elect to use SSH, stunnel, and other technologies that rely on port forwarding. With IPSEC, you simply have to run a program and its configuration file. After running it, encryption between hosts is mandatory. Connections will be denied if the other connection does not have the appropriate keys. Groups of computers can share the same key, and it can even be done on a per-port setting.</p>
<p><a href="http://linuxexplore.files.wordpress.com/2013/04/n-t-n-ipsec-diagram.png"><img class="aligncenter size-full wp-image-759" alt="IPSec image" src="http://linuxexplore.files.wordpress.com/2013/04/n-t-n-ipsec-diagram.png" width="600" height="186" /></a></p>
<p>To configure the IPSec between servers following are the requirements:</p>
<ul>
<li>IPSec-tools package</li>
<li>Static IP address for each system</li>
</ul>
<p>IPSec-tools can be downloaded from <a href="http://ipsec-tools.sourceforge.net/">http://ipsec-tools.sourceforge.net/</a>.</p>
<h2>Installation IPSec-tools package:</h2>
<p>To install give the following commands:</p>
<pre># <strong>tar jxf ipsec-tools-x.y.z.tar.bz2
</strong># <strong>cd ipsec-tools-x.y.z
</strong># <strong>./configure
</strong># <strong>make
</strong># <strong>make install</strong></pre>
<p>If you get error in compilation, please go through the comments. You will find the solution.</p>
<p>Replace <em>x.y.z</em> with the version of the downloaded sources.</p>
<p>Instead of compiling and installing IPSec-tools from source, it can be done using CentOS repository:</p>
<pre># <strong>yum install ipsec-tools
</strong></pre>
<p><!--[if gte mso 9]&gt;--></p>
<h2>IPSec communication between two Linux systems</h2>
<h3><span style="text-decoration:underline;">Using Pre-shared key authentication method:</span></h3>
<p>Linux to <strong>Linux IPSec communication</strong> can be used to secure the communication between Server (IP address: 192.168.1.1) to Server (IP address: 192.168.1.2). It can also be used to encrypt the <strong>client-sever communication. </strong>For example: L2TP VPN Server and client communication, VNC server and client communication can be secured using ipsec-tools. For both cases following steps need to be followed.</p>
<p>The first step is to write a configuration file <code>/etc/raccoon/setkey.conf </code>with following entries on 192.168.1.1.</p>
<pre>#!/usr/sbin/setkey -f
# Flush the SAD and SPD
flush;
spdflush;
spdadd 192.168.1.1 192.168.1.2 any -P out ipsec
        esp/transport//require;
spdadd 192.168.1.2 192.168.1.1 any -P in ipsec
        esp/transport//require;</pre>
<p>The same <code>/etc/setkey.conf</code> can be created on the 192.168.1.2 host, with inverted <code><i>-P in</i></code> and <code><i>-P out</i></code> options.</p>
<pre>#!/usr/sbin/setkey -f
# Flush the SAD and SPD
flush;
spdflush;
spdadd 192.168.1.1 192.168.1.2 any -P in ipsec
        esp/transport//require;
spdadd 192.168.1.2 192.168.1.1 any -P out ipsec
        esp/transport//require;</pre>
<p>With the security policies set up you can configure <strong>racoon</strong>. We will add paths for the preshared key file, and certification directory. This is an example of <code>/etc/racoon.conf</code> with the paths and a general phase two policy set up:</p>
<pre>path pre_shared_key "/etc/racoon/psk.txt";
path certificate "/etc/racoon/certs";
sainfo anonymous {
{
        pfs_group 2;
        lifetime time 1 hour;
        encryption_algorithm 3des, blowfish 448, rijndael;
        authentication_algorithm hmac_sha1, hmac_md5;
        compression_algorithm deflate;
}</pre>
<p>The <code><i>sainfo</i></code> identifier is used to make a block that specifies the settings for security associations. Instead of setting this for a specific host, the <code><i>anonymous</i></code> parameter is used to specify that these settings should be used for all hosts that do not have a specific configuration. The <code><i>pfs_group</i></code> specifies which group of Diffie-Hellman exponentiations should be used. The different groups provide different lengths of base prime numbers that are used for the authentication process. Group 2 provides a 1024 bit length if you would like to use a greater length, for increased security, you can use another group (like 14 for a 2048 bit length). The <code><i>encryption_algorithm</i></code> specifies which encryption algorithms this host is willing to use for ESP encryption. The <code><i>authentication_algorithm</i></code> specifies the algorithm to be used for ESP Authentication or AH. Finally, the <code><i>compression_algorithm</i></code> is used to specify which compression algorithm should be used when IPcomp is specified in an association.</p>
<p>The next step is to add a phase one configuration for the key exchange with the other host to the <code>racoon.conf</code> configuration file.</p>
<pre>remote 192.168.1.2
{
        exchange_mode aggressive, main;
        my_identifier address;
        proposal {
               encryption_algorithm 3des;
               hash_algorithm sha1;
               authentication_method pre_shared_key;
               dh_group 2;
        }
}</pre>
<p>The <code><i>remote</i></code> block specifies a phase one configuration. The <code><i>exchange_mode</i></code> is used to configure what exchange mode should be used for phase. You can specify more than one exchange mode, but the first method is used if this host is the initiator of the key exchange. The <code><i>my_identifier</i></code> option specifies what identifier should be sent to the remote host. If this option committed <code><i>address</i></code> is used, this sends the IP address as the identifier. The <code><i>proposal</i></code> block specifies parameter that will be proposed to the other host during phase one authentication. The <code><i>encryption_algorithm</i></code>, and <code><i>dh_group</i></code> are explained above. The <code><i>hash_algorithm</i></code> option is mandatory, and configures the hash algorithm that should be used. This can be <code><i>md5</i></code>, or <code><i>sha1</i></code>. The <code><i>authentication_method</i></code> is crucial for this configuration, as this parameter is used to specify that a preshared key should be used, with <code><i>pre_shared_key</i></code>.</p>
<p>With racoon set up there is one thing left to do, the preshared key has to be added to <code>/etc/racoon/psk.txt</code>. The syntax is very simple, each line contains a host IP address and a key. These parameters are separated with a tab. For example:</p>
<pre>192.168.1.2    somekey</pre>
<p>Now time to test the security policies &amp; raccoon configuration.</p>
<pre>$ <strong>setkey -f /etc/setkey.conf</strong>
$ <strong>racoon -F</strong></pre>
<p>For instance, you could ping the other host to start with. The first time you ping the other host, this will fail:</p>
<pre>$ <strong>ping 192.168.1.2</strong>
connect: Resource temporarily unavailable</pre>
<p>But after some time you will get reply. Now all the communication between IP addresses 192.168.1.1 and 192.168.1.2 is secured with IPSec. Instead of making complete secure communication, it can be changed port specific, which can be used for <strong>client-server secure communication</strong>. It just need to modify /etc/setkey.conf file for port specific configuration.</p>
<p>Check related posts: <a href="http://linuxexplore.com/how-tos/l2tp-vpn-using-rp-l2tpd/" target="_blank">how to configure L2TP VPN on CentOS using rp-l2tpd</a> and <a href="http://linuxexplore.com/how-tos/l2tp-vpn-using-xl2tpd/" target="_blank">how to configure L2TP VPN on CentOS using xl2tpd</a></p>
]]></content:encoded>
			<wfw:commentRss>https://blog.linuxexplore.com/2013/04/07/ipsec-communication-for-vpn-setup-in-centos-6-rhel-6-3/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
