<?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>Paulo Nobre &#187; Openswan</title>
	<atom:link href="http://www.paulonobre.net/tags/openswan/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.paulonobre.net</link>
	<description></description>
	<lastBuildDate>Mon, 08 Feb 2010 23:42:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting up IPSEC/L2TP with NAT-T (Server)</title>
		<link>http://www.paulonobre.net/2010/01/18/setting-up-ipsec-l2tp-vpn-server-with-nat-t/</link>
		<comments>http://www.paulonobre.net/2010/01/18/setting-up-ipsec-l2tp-vpn-server-with-nat-t/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 00:38:37 +0000</pubDate>
		<dc:creator>Paulo Nobre</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Openswan]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://www.paulonobre.net/2010/01/18/setting-up-ipsec-l2tp-vpn-server-with-nat-t/</guid>
		<description><![CDATA[Since my last post, I’ve been a little busy with some projects. In my spare time, I was getting gentoo installed and configured in a spare mac mini I have at home. Yes, I’m a geek and gentoo is my favorite Linux distro.
I don’t think of my self as a security paranoid guy (if someone [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">Since my last post, I’ve been a little busy with some projects. In my spare time, I was getting <a href="http://www.gentoo.org" target="_blank">gentoo</a> installed and configured in a spare mac mini I have at home. Yes, I’m a geek and <a href="http://www.gentoo.org" target="_blank">gentoo</a> is my favorite Linux distro.</p>
<p>I don’t think of my self as a security paranoid guy (if someone possesses the knowledge and wants to hack you, he/she will hack you anyway, unless you aren’t connected to the net) , however, whenever i see my apache logs and find out some guys where scanning it for phpmyadmin (DISCLAIMER: I DON’T FUCKING USE PHPMYADMIN !!!!! I USE mysql –u someuser –p somedatabasename !!!!) I freak out. Anyway, I decided to access my home network using a vpn. First I’ve tried OpenVPN, but I just found out it’s too slow (beside having to install some client on windows). </p>
<p>After a week tweaking ipsec.conf settings, you’ll laugh at the the end of this article, but (at least for future reference) I’ll describe the (hopefully less) painful steps to get this configuration working in <a href="http://www.gentoo.org" target="_blank">gentoo</a>.</p>
<p>Before start I definitely recommend you get your hands on <a href="http://www.packtpub.com/openswan/book" target="_blank">this book</a>. It’s very helpful and&#160; you’ll get to understart the nitty-gritty details of openswan and the ipsec protocol (among others).</p>
<p><strong>Configuring your kernel: </strong></p>
<p>If you don’t have it done already compile your kernel with ipsec, ah and esp transformation, netfilter and ppp. Also, on cryptographic options, turn on Cryptographic APICompile it and install. Reboot and verify everything works as expected. These were the specific options I selected (among with other I had already selected) on my kernel’s configuration: </p>
<p>Networking support&#160; &#8212;&gt;    <br />&#160;&#160; Networking options&#160; &#8212;&gt;     <br />&#160;&#160;&#160;&#160;&#160; &lt;*&gt; PF_KEY socket&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160; [*] TCP/IP networking     <br />&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; IP: AH transformation     <br />&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; IP: ESP transformation     <br />&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; IP: IPComp transformation     <br />&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; IP: IPsec transport mode     <br />&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; IP: IPsec tunnel mode </p>
<p>&#160;&#160; Device Drivers &#8212;&gt;    <br />&#160;&#160;&#160;&#160;&#160; [*] Network device support&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt; PPP (point-to-point protocol) support     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; PPP support for async serial ports     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; PPP support for sync tty ports     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; PPP Deflate compression&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; PPP BSD-Compress compression     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; PPP over Ethernet (EXPERIMENTAL)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt;&#160;&#160; PPP over L2TP (EXPERIMENTAL)     <br />&#160;&#160;&#160;&#160;&#160; Character devices&#160; &#8212;&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- Unix98 PTY support </p>
<p>&#160;&#160; Cryptographic API &#8212;&gt;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt; Null Algorithms     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- HMAC support     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- MD5 digest algorithm     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- SHA1 digest algorithm     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- AES chiper algorithms     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- DES and Triple DES EDE cipher algorithms     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; -*- Deflate compression algorithm     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt; Zlib compression algorithm     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;*&gt; LZO compression algorithm&#160;&#160;&#160; </p>
<p>After reboot, everything was working, so I emerged openswan, ppp, xl2tp and ipsec-tools packages. I had to unmask ipsec-tools.</p>
<p>echo &quot;net-firewall/ipsec-tools ~x86&quot; &gt;&gt; /etc/portage/package.keywords</p>
<p>Also, during emerge ipsec-tools, I got some error about swab.h not being found on my system (I’m running 2.6.31 kernel, and don’t know why, but portage only had 2.6.27 linux headers. I solved this problem creating a symlink from /usr/src/linux/arch/x86/include/asm/swab.h to /usr/include/asm/swab.h</p>
<p># ln -s /usr/src/linux/arch/x86/include/asm/swab.h /usr/include/asm/swab.h    <br /># emerge -av net-firewall/ipsec-tools     <br /># rm /usr/include/asm/swab.h </p>
<p>After emerge completed successfully, I removed the symlink.</p>
<p>As stated on <a href="http://www.packtpub.com/openswan/book" target="_blank">openswan book</a> I turned on ip forward, and turned off send redirects and accept redirects. On gentoo you can edit /etc/sysctl.conf and set the default options there.</p>
<p>All my certificate stuff was generated as explained on the book and my configuration was almost verbatim the book’s examples (leftnexthop on ipsec.conf is the nat gateway’s ip address): </p>
<p><strong>/etc/ipsec/ipsec.conf</strong>:</p>
<p>version 2.0</p>
<p>config setup    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; nat_traversal=yes     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; nhelpers=0     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; plutodebug=&quot;control parsing&quot;</p>
<p>conn L2TP-X509    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; authby=rsasig     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; pfs=no     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rekey=no     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; keyingtries=3     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; left=%defaultroute     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; leftprotoport=17/1701     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; leftrsasigkey=%cert     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; leftcert=servercert.pem     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; leftnexthop=192.168.112.1     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; right=%any     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rightprotoport=17/%any     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rightrsasigkey=%cert     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; auto=add     </p>
<p><strong>/etc/xl2tpd/xl2tpd.conf:</strong></p>
<p>[global]    <br />listen-addr = 192.168.112.128</p>
<p>[lns default]    <br />ip range = 192.168.112.241-192.168.112.254     <br />local ip = 192.168.112.240     <br />require chap = yes     <br />refuse pap = yes     <br />require authentication = yes     <br />name = test     <br />ppp debug = yes     <br />pppoptfile = /etc/ppp/options.l2tpd     <br />length bit = yes</p>
<p><strong>/etc/ppp/options.l2tpd:</strong></p>
<p>ipcp-accept-local    <br />ipcp-accept-remote     <br />ms-dns 192.168.112.1     <br />noccp     <br />auth     <br />crtscts     <br />idle 1800     <br />mtu 1200     <br />mru 1200     <br />nodefaultroute     <br />debug     <br />lock     <br />proxyarp     <br />connect-delay 5000     </p>
<p><strong>/etc/ppp/chap-secrets</strong></p>
<p>vpnuser&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; *&#160;&#160;&#160;&#160;&#160; vPnP@ssVVd1234&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 192.168.112.241/28</p>
<p>(it’s obvious this username and password doesn’t work on my real vpn setup, it’s just an example).</p>
<p>And that was the openswan setup. After that I started openswan, and added it to the default runlevel. On my next article (hopefully shorter than this one, I’ll describe the windows client setup).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulonobre.net/2010/01/18/setting-up-ipsec-l2tp-vpn-server-with-nat-t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
