<?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>Unwinding the Stack &#187; vpnc</title>
	<atom:link href="http://thestaticvoid.com/tag/vpnc/feed/" rel="self" type="application/rss+xml" />
	<link>http://thestaticvoid.com</link>
	<description>Explorations in Computing</description>
	<lastBuildDate>Wed, 07 Dec 2011 16:15:58 +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>Fun With vpnc</title>
		<link>http://thestaticvoid.com/post/2010/07/22/fun-with-vpnc/</link>
		<comments>http://thestaticvoid.com/post/2010/07/22/fun-with-vpnc/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 20:20:20 +0000</pubDate>
		<dc:creator>James Lee</dc:creator>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[snoop]]></category>
		<category><![CDATA[vpnc]]></category>

		<guid isPermaLink="false">http://thestaticvoid.com/?p=337</guid>
		<description><![CDATA[I recently got a new laptop at work and I decided to put OpenSolaris on it. This meant I had to setup vpnc in order to access the server networks and wireless here. I installed my vpnc package, copied the profile from my Ubuntu workstation, and started it up. It connected, but no packets flowed. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got a new laptop at work and I decided to put OpenSolaris on it.  This meant I had to setup vpnc in order to access the server networks and wireless here.  I installed <a href="http://thestaticvoid.com/post/2010/02/26/vpnc-for-opensolaris/">my vpnc package</a>, copied the profile from my Ubuntu workstation, and started it up.  It connected, but no packets flowed.  I didn&#8217;t have time to investigate, so I decided to work on it some more at home.</p>
<p>The strange thing is that it connected from home with the very same profile and everything worked fine.  I immediately suspected something was wrong with the routing tables, like maybe some of the routes installed by <tt>vpnc-script</tt> were conflicting with the routes necessary to talk to the VPN concentrator.  I endlessly compared the routing tables between work and home and my working Ubuntu workstation, removing routes, adding routes, and manually constructing the routing table until I was positive it could not be that.</p>
<p>Everything I pinged worked.  I could ping the concentrator.  I could ping the gateway.  I could ping the tunnel device.  I could ping the physical interface&#8212;or so I thought.</p>
<p>As I was preparing to write a message to the <a href="http://news.gmane.org/gmane.network.vpnc.devel">vpnc-devel mailing list</a> requesting help, I did some pings to post the output in the email.  I ran</p>
<pre class="terminal">
$ <kbd>ping &lt;concentrator ip&gt;</kbd>
&lt;concentrator ip&gt; is alive
</pre>
<p>which looked good, but I wanted the full ping output, so I ran</p>
<pre class="terminal">
$ <kbd>ping -s &lt;concentrator ip&gt;</kbd>
PING &lt;concentrator ip&gt;: 56 data bytes
^C
----&lt;concentrator ip&gt; PING Statistics----
4 packets transmitted, 1 packets received, 75% packet loss
round-trip (ms)  min/avg/max/stddev = 9223372036854776.000/0.000/0.000/-NaN
</pre>
<p>For some reason, only the first ping was getting through.  The rest were getting hung up somewhere.  The really strange thing was that I saw the same behavior on the local physical interface:</p>
<pre class="terminal">
$ <kbd>ifconfig bge0</kbd>
bge0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 3
        inet 161.253.143.151 netmask ffffff00 broadcast 161.253.143.255
$ <kbd>ping -s 161.253.143.151</kbd>
PING 161.253.143.151: 56 data bytes
^C
----161.253.143.151 PING Statistics----
5 packets transmitted, 1 packets received, 80% packet loss
round-trip (ms)  min/avg/max/stddev = 9223372036854776.000/0.000/0.000/-NaN
</pre>
<p>I have never seen a situation where you couldn&#8217;t even ping a local physical interface!  I checked and double checked that IPFilter wasn&#8217;t running.  Finally I started a packet capture of the physical interface to see what was happening to my pings:</p>
<pre class="terminal">
# <kbd>snoop -d bge0 icmp</kbd>
Using device bge0 (promiscuous mode)
161.253.143.151 -> &lt;concentrator ip&gt; ICMP Destination unreachable (Bad protocol 50)
161.253.143.151 -> &lt;concentrator ip&gt; ICMP Destination unreachable (Bad protocol 50)
161.253.143.151 -> &lt;concentrator ip&gt; ICMP Destination unreachable (Bad protocol 50)
^C
</pre>
<p>That&#8217;s when by chance I saw messages being sent to the VPN concentrator saying &#8220;bad protocol 50.&#8221;  <a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml">IP protocol</a> 50 represents &#8220;ESP&#8221;, commonly used for IPsec.  Apparently Solaris eats these packets.  Haven&#8217;t figured out why.</p>
<p>I remembered seeing something in the vpnc manpage about ESP packets:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">--natt-mode &lt;natt/none/force-natt/cisco-udp&gt;<br />
<br />
&nbsp; &nbsp; &nbsp; Which NAT-Traversal Method to use:<br />
&nbsp; &nbsp; &nbsp; o &nbsp; &nbsp;natt -- NAT-T as defined in RFC3947<br />
&nbsp; &nbsp; &nbsp; o &nbsp; &nbsp;none -- disable use of any NAT-T method<br />
&nbsp; &nbsp; &nbsp; o &nbsp; &nbsp;force-natt -- always use NAT-T encapsulation &nbsp;even<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;without presence of a NAT device (useful if the OS<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;captures all ESP traffic)<br />
&nbsp; &nbsp; &nbsp; o &nbsp; &nbsp;cisco-udp -- Cisco proprietary UDP &nbsp;encapsulation,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;commonly over Port 10000</div></div>
<p>I enabled <tt>force-natt</tt> mode, which encapsulates the ESP packet in a UDP packet, normally to get past NAT, and it started working!  In retrospect, I should have been able to figure that out much easier.  First, it pretty much says it on the <a href="http://www.unix-ag.uni-kl.de/~massar/vpnc/">vpnc homepage</a>: &#8220;Solaris (7 works, 9 only with &#8211;natt-mode forced).&#8221;  I didn&#8217;t even notice that.  Second, I should have realized that I was behind a NAT at home and not at work, so they would be using a different NAT-traversal mode by default.  Oh well, it was a good diagnostic exercise, hence the post to share the experience.</p>
<p>In other vpnc related news, I&#8217;ve ported <a href="http://www.whiteboard.ne.jp/~admin2/tuntap/">Kazuyoshi&#8217;s</a> <a href="http://www.whiteboard.ne.jp/~admin2/tuntap/source/openvpn/patch.openvpn-2.1.1.tun.c">patch</a> to the <tt>open_tun</tt> and <tt>solaris_close_tun</tt> functions of OpenVPN to the <tt>tun_open</tt> and <tt>tun_close</tt> functions of vpnc.  His sets up the tunnel interface a little bit differently and adds TAP support.  It solves the random problems vpnc had with bringing up the tunnel interface such as:</p>
<pre class="terminal">
# <kbd>ifconfig tun0</kbd>
tun0: flags=10010008d0&lt;POINTOPOINT,RUNNING,NOARP,MULTICAST,IPv4,FIXEDMTU&gt; mtu 1412 index 8
        inet 128.164.xxx.yy --> 128.164.xxx.yy netmask ffffffff
        ether f:ea:1:ff:ff:ff
# <kbd>ifconfig tun0 up</kbd>
ifconfig: setifflags: SIOCSLIFFLAGS: tun0: no such interface
# <kbd>dmesg | grep tun0</kbd>
Jul 23 14:56:05 swan ip: [ID 728316 kern.error] tun0: DL_BIND_REQ failed: DL_OUTSTATE
</pre>
<p>The changes are in the latest vpnc package available from my <a href="http://pkg.thestaticvoid.org:10000/">package repository</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thestaticvoid.com/post/2010/07/22/fun-with-vpnc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>VPNC for OpenSolaris</title>
		<link>http://thestaticvoid.com/post/2010/02/26/vpnc-for-opensolaris/</link>
		<comments>http://thestaticvoid.com/post/2010/02/26/vpnc-for-opensolaris/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 20:02:16 +0000</pubDate>
		<dc:creator>James Lee</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[vpnc]]></category>

		<guid isPermaLink="false">http://thestaticvoid.com/?p=260</guid>
		<description><![CDATA[I&#8217;ve compiled VPNC and the requisite TUN/TAP driver for OpenSolaris so that I can access my work network from home. Kazuyoshi&#8217;s driver adds TAP functionality to the original TUN driver which hasn&#8217;t been updated in nine years. It&#8217;s a real testament to the stability of the OpenSolaris kernel ABI that the module still compiles, loads, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve compiled <a href="http://www.unix-ag.uni-kl.de/~massar/vpnc/">VPNC</a> and the requisite <a href="http://www.whiteboard.ne.jp/~admin2/tuntap/">TUN/TAP driver</a> for OpenSolaris so that I can access my work network from home.  Kazuyoshi&#8217;s driver adds TAP functionality to the original <a href="http://vtun.sourceforge.net/tun/">TUN driver</a> which hasn&#8217;t been updated in nine years.  It&#8217;s a real testament to the stability of the OpenSolaris kernel ABI that the module still compiles, loads, and works properly.</p>
<p>All of the software can be installed from my repository onto build 111 or higher:</p>
<pre class="terminal">
$ <kbd>pfexec pkg set-publisher -O http://pkg.thestaticvoid.com/ thestaticvoid</kbd>
$ <kbd>pfexec pkg install vpnc</kbd>
</pre>
<p>The tun driver should load automatically and create <tt>/dev/tun</tt>.  Now create a VPN profile configuration in <tt>/etc/vpnc/</tt>.  The configuration contains a lot of private information so I&#8217;m not going to share mine here, but <tt>/etc/vpnc/default.conf</tt> is a good start.</p>
<p>One thing I do like to do is make sure only certain subnets are tunneled through the VPN.  That way connecting to the VPN doesn&#8217;t interrupt any connections that are already established (for example, AIM).  To do that I create a script <tt>/etc/vpnc/gwu-networks-script</tt> containing</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Only tunnel GWU networks through VPN</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC</span>=<span style="color: #000000;">2</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_0_ADDR</span>=161.253.0.0<br />
<span style="color: #007800;">CISCO_SPLIT_INC_0_MASK</span>=255.255.0.0<br />
<span style="color: #007800;">CISCO_SPLIT_INC_0_MASKLEN</span>=<span style="color: #000000;">16</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_0_PROTOCOL</span>=<span style="color: #000000;">0</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_0_SPORT</span>=<span style="color: #000000;">0</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_0_DPORT</span>=<span style="color: #000000;">0</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_1_ADDR</span>=128.164.0.0<br />
<span style="color: #007800;">CISCO_SPLIT_INC_1_MASK</span>=255.255.0.0<br />
<span style="color: #007800;">CISCO_SPLIT_INC_1_MASKLEN</span>=<span style="color: #000000;">16</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_1_PROTOCOL</span>=<span style="color: #000000;">0</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_1_SPORT</span>=<span style="color: #000000;">0</span><br />
<span style="color: #007800;">CISCO_SPLIT_INC_1_DPORT</span>=<span style="color: #000000;">0</span><br />
<br />
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vpnc<span style="color: #000000; font-weight: bold;">/</span>vpnc-script</div></div>
<p>then add <tt>Script /etc/vpnc/gwu-networks-script</tt> to the end of my VPN profile configuration.</p>
<p>Connecting to the VPN you should see messages like:</p>
<pre class="terminal">
$ <kbd>pfexec vpnc gwu</kbd>
Enter password for jameslee@&lt;no&gt;:
which: no ip in (/sbin:/usr/sbin:/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin)
which: no ip in (/sbin:/usr/sbin:/usr/gnu/bin:/usr/bin:/usr/sbin:/sbin)
add net 128.164.&lt;no&gt;: gateway 128.164.&lt;no&gt;
add host 128.164.&lt;no&gt;: gateway 161.253.&lt;no&gt;
add net 161.253.0.0: gateway 128.164.&lt;no&gt;
add net 128.164.0.0: gateway 128.164.&lt;no&gt;
add net 128.164.&lt;no&gt;: gateway 128.164.&lt;no&gt;
add net 128.164.&lt;no&gt;: gateway 128.164.&lt;no&gt;
VPNC started in background (pid: 594)...
</pre>
<p>The <tt>vpnc-script</tt> will modify your <tt>/etc/resolv.conf</tt> and routing tables so be sure to run <tt>vpnc-disconnect</tt> when you are done with the connection to restore the original configuration.</p>
<p>Thanks to the good folks at <a href="http://www.infradead.org/openconnect.html">OpenConnect</a> for a well-maintained <a href="http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob/HEAD:/vpnc-script"><tt>vpnc-script</tt></a> which works on Solaris.  Spec files for these packages are available from my <a href="https://github.com/MrStaticVoid/specs/blob/master/vpnc.spec">GitHub</a> <a href="https://github.com/MrStaticVoid/specs/blob/master/tuntap.spec">repository</a> if you want to roll your own.</p>
]]></content:encoded>
			<wfw:commentRss>http://thestaticvoid.com/post/2010/02/26/vpnc-for-opensolaris/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

