<?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>Alessio Molteni Dot Com &#187; vpnc</title>
	<atom:link href="http://www.alessiomolteni.com/tag/vpnc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alessiomolteni.com</link>
	<description>Tutto su di me e sulle mia fotografie</description>
	<lastBuildDate>Wed, 11 Nov 2009 14:09:15 +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>Windows 7 64 bit &#8211; Cisco VPN with CygWin VPNC client</title>
		<link>http://www.alessiomolteni.com/2009/10/28/windows-7-64-bit-cisco-vpn-with-cygwin-vpnc-client/</link>
		<comments>http://www.alessiomolteni.com/2009/10/28/windows-7-64-bit-cisco-vpn-with-cygwin-vpnc-client/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 17:46:20 +0000</pubDate>
		<dc:creator>Alessio Molteni</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vpnc]]></category>
		<category><![CDATA[Windows7]]></category>

		<guid isPermaLink="false">http://www.alessiomolteni.com/?p=72</guid>
		<description><![CDATA[I&#8217;ve found that Cisco did not release their VPN Client for 64 bit machines&#8230;. so&#8230;. who cares ! The problem could be addressed using cygwin and vpnc opensource client. This tutorial is suitable for people who are a little bit confortable with unix like shell or similar, I will not detail every step such as [...]]]></description>
			<content:encoded><![CDATA[<div>I&#8217;ve found that Cisco did not release their VPN Client for 64 bit machines&#8230;. so&#8230;. who cares !</div>
<div>The problem could be addressed using cygwin and vpnc opensource client.</div>
<div>This tutorial is suitable for people who are a little bit confortable with unix like shell or similar, I will not detail every step such as the cygwin installation steps.</div>
<div>Let&#8217;s begin !</div>
<div>P.s I based this article starting from what I&#8217;ve found <a title="here" href="http://www.theologyweb.com/campus/showthread.php?p=2148649">here</a> , thanks to &#8220;Salty&#8221;.</div>
<div><span id="more-72"></span></div>
<p style="text-align: right;">
<div>1- Install CygWin in Windows 7: http://www.cygwin.com</div>
<p style="text-align: right;">
<div>You should install those packages in addition to the base system:</div>
<div style="padding-left: 30px;">- gcc-core</div>
<div style="padding-left: 30px;">- libgcrypt-devel</div>
<div style="padding-left: 30px;">- make</div>
<div style="padding-left: 30px;">- perl</div>
<p style="text-align: right;">
<div>2- You will find on your Desktop the Cygwin link to open the bash prompt.</div>
<p style="text-align: right;">
<div>3- Modify the bash.exe executable to &#8220;Run as Administrator&#8221;: go to c:\cygwin\bin search bash.exe, right click on it, go to the &#8220;Compatibility&#8221; tab and flag &#8220;Run as Administrator&#8221;</div>
<p style="text-align: right;">
<div>4- Go to http://www.unix-ag.uni-kl.de/~massar/vpnc/ and download vpnc-0.5.3.tar.gz</div>
<p style="text-align: right;">
<div>5- Uncompress the tarball with the command &#8220;tar xvfz vpnc-0.5.3.tar.gz&#8221;</div>
<p style="text-align: right;">
<div>6- Enter the vpnc-0.5.3 directory with &#8220;cd vpnc-0.5.3&#8243;</div>
<p style="text-align: right;">
<div>7- Compile and install the vpnc client launcing the command &#8220;make install&#8221;</div>
<p style="text-align: right;">
<div>8- Download and Install OpenVPN from http://openvpn.net/index.php/open-source/downloads.html openvpn-2.1_rc20-install.exe</div>
<p style="text-align: right;">
<div>9- Run the OpenVPN Installater and deselct everything but TAP-Win32 Adapter V9</div>
<p style="text-align: right;">
<div>10- Check the Control Panel &#8211;&gt; Network Connection and rename the TAP device as &#8220;VPN&#8221;</div>
<p style="text-align: right;">
<div>11- Create a configuration file in /etc/vpnc/default.conf as the following:</div>
<p style="text-align: right;">
<p>[bash]<br />
IPSec gateway YOURGATEWAY<br />
IPSec ID YOURID<br />
IPSec obfuscated secret YOURREALYLONGHEXVALUE (you can use your clear text password here if you remove obfuscated)<br />
Xauth username YOURUSERNAME<br />
Xauth password YOURPASSWORD<br />
Interface name VPN<br />
Interface mode tap<br />
Local Port 0</p>
<p>[/bash]</p>
<div>12- Now you have to modify the file c:\cygwin\etc\vpnc\vpnc-script-win.js, I&#8217;ve modified what I&#8217;ve found on the Theology Web site I mentioned at the top of this article.</div>
<div>
[js]<br />
// vpnc-script-win.js<br />
//<br />
// Sets up the Network interface and the routes<br />
// needed by vpnc.</p>
<p>// &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
// Utilities<br />
// &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>function echo(msg)<br />
{<br />
	WScript.echo(msg);<br />
}</p>
<p>function run(cmd)<br />
{<br />
	return (ws.Exec(cmd).StdOut.ReadAll());<br />
}</p>
<p>// function getDefaultGateway()<br />
// {<br />
// 	if (run(&quot;route print&quot;).match(/Default Gateway: *(.*)/)) {<br />
// 		return (RegExp.$1);<br />
// 	}<br />
// 	return (&quot;&quot;);<br />
// }</p>
<p>function getDefaultGateway()<br />
{<br />
var stuff = run(&quot;route print 0.0.0.0 mask 0.0.0.0&quot;);<br />
var res;<br />
var inal;<br />
//echo (&quot;Stuff&quot; + stuff);<br />
	if (res = stuff.match(/0.0.0.0 *(.*) 0.0.0.0 *(.*)10/)) {<br />
	// echo (&quot;RegExp: &quot;+RegExp.$1+&quot;2: &quot;+ RegExp.$2+&quot; 3:&quot;+RegExp.$3);<br />
	//echo (&quot;res :&quot; + res[0]+&quot; THE END!!!&quot;);<br />
	inal = res[0].split(/\s/);<br />
		for (var i = 0; i &lt; inal.length; i++) {<br />
			echo (&quot;inal :&quot; + inal[i]);<br />
		} </p>
<p>	return (inal[2]);<br />
	}<br />
return (&quot;&quot;);<br />
} </p>
<p>function getDefaultGatewayOnDisconnect()<br />
{<br />
var stuff = run(&quot;route print &quot; + env(&quot;VPNGATEWAY&quot;) + &quot; mask 255.255.255.255&quot;);<br />
var res;<br />
var inal;<br />
//echo (&quot;Stuff&quot; + stuff);<br />
	if (res = stuff.match(new RegExp(env(&quot;VPNGATEWAY&quot;) + &quot; *(.*) 255.255.255.255 *(.*)10&quot;,&quot;ig&quot;))) {<br />
	//echo (&quot;RegExp: &quot;+RegExp.$1+&quot;2: &quot;+ RegExp.$2+&quot; 3:&quot;+RegExp.$3);<br />
	//echo (&quot;res :&quot; + res[0]+&quot; THE END!!!&quot;);<br />
	inal = res[0].split(/\s/);<br />
		for (var i = 0; i &lt; inal.length; i++) {<br />
			echo (&quot;inal :&quot; + inal[i]);<br />
		} </p>
<p>	return (inal[2]);<br />
	}<br />
return (&quot;&quot;);<br />
} </p>
<p>// &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
// Script starts here<br />
// &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>var internal_ip4_netmask = &quot;255.255.255.0&quot;</p>
<p>var ws = WScript.CreateObject(&quot;WScript.Shell&quot;);<br />
var env = ws.Environment(&quot;Process&quot;);</p>
<p>switch (env(&quot;reason&quot;)) {<br />
case &quot;pre-init&quot;:<br />
	break;<br />
case &quot;connect&quot;:<br />
	var gw = getDefaultGateway();<br />
	echo(&quot;Default GW: &quot; + gw );<br />
	echo(&quot;VPN Gateway: &quot; + env(&quot;VPNGATEWAY&quot;));<br />
	echo(&quot;Internal Address: &quot; + env(&quot;INTERNAL_IP4_ADDRESS&quot;));<br />
  	echo(&quot;Internal Netmask: &quot; + env(&quot;INTERNAL_IP4_NETMASK&quot;));<br />
	echo(&quot;Interface: \&quot;&quot; + env(&quot;TUNDEV&quot;) + &quot;\&quot;&quot;);</p>
<p>	if (env(&quot;INTERNAL_IP4_NETMASK&quot;)) {<br />
	    internal_ip4_netmask = env(&quot;INTERNAL_IP4_NETMASK&quot;);<br />
	}</p>
<p>	echo(&quot;Configuring \&quot;&quot; + env(&quot;TUNDEV&quot;) + &quot;\&quot; interface&#8230;&quot;);</p>
<p>	run(&quot;netsh interface ip set address \&quot;&quot; + env(&quot;TUNDEV&quot;) + &quot;\&quot; static &quot; +<br />
	    env(&quot;INTERNAL_IP4_ADDRESS&quot;) + &quot; &quot; + internal_ip4_netmask);</p>
<p>	echo(&quot;Delete Default Route  Output: &quot; + run(&quot;route delete  0.0.0.0 mask 0.0.0.0&quot;));<br />
	echo(&quot;Waiting 5 seconds to add new default route&#8230;&quot;);<br />
	run(&quot;sleep 5&quot;);<br />
	echo(&quot;Adding new VPN Default Route: &quot; + run(&quot;route add 0.0.0.0 mask 0.0.0.0 &quot; + env(&quot;INTERNAL_IP4_ADDRESS&quot;)));<br />
	echo(&quot;&quot;);</p>
<p>	// Add direct route for the VPN gateway to avoid routing loops<br />
	echo(&quot;Add direct route for the VPN gateway to avoid routing loops&quot;);<br />
	echo(&quot;route add &quot; + env(&quot;VPNGATEWAY&quot;) + &quot; mask 255.255.255.255 &quot; + gw);<br />
	run(&quot;route add &quot; + env(&quot;VPNGATEWAY&quot;) +<br />
            &quot; mask 255.255.255.255 &quot; + gw);</p>
<p>	echo(&quot;Checking for WINS Servers&#8230;&quot;);<br />
        if (env(&quot;INTERNAL_IP4_NBNS&quot;)) {<br />
		echo(&quot;WINS Found, adding them to the TAP Device&#8230;&quot;);<br />
		var wins = env(&quot;INTERNAL_IP4_NBNS&quot;).split(/ /);<br />
		for (var i = 0; i &lt; wins.length; i++) {<br />
	                run(&quot;netsh interface ip add wins \&quot;&quot; +<br />
			    env(&quot;TUNDEV&quot;) + &quot;\&quot; &quot; + wins[i]<br />
  			    + &quot; index=&quot; + (i+1));<br />
		}<br />
	}</p>
<p>	echo(&quot;Checking for DNS Servers&#8230;&quot;);<br />
        if (env(&quot;INTERNAL_IP4_DNS&quot;)) {<br />
		echo(&quot;DNS Found, adding them to the TAP Device&#8230;&quot;);<br />
		var dns = env(&quot;INTERNAL_IP4_DNS&quot;).split(/ /);<br />
		for (var i = 0; i &lt; dns.length; i++) {<br />
	                run(&quot;netsh interface ip add dns \&quot;&quot; +<br />
			    env(&quot;TUNDEV&quot;) + &quot;\&quot; &quot; + dns[i]<br />
  			    + &quot; index=&quot; + (i+1));<br />
		}<br />
	}</p>
<p>	echo(&quot;done.&quot;);</p>
<p>	// Add internal network routes<br />
        echo(&quot;Configuring networks:&quot;);</p>
<p>        if (env(&quot;CISCO_SPLIT_INC&quot;)) {<br />
	    	for (var i = 0 ; i &lt; parseInt(env(&quot;CISCO_SPLIT_INC&quot;)); i++) {<br />
			var network = env(&quot;CISCO_SPLIT_INC_&quot; + i + &quot;_ADDR&quot;);<br />
			var netmask = env(&quot;CISCO_SPLIT_INC_&quot; + i + &quot;_MASK&quot;);<br />
			var netmasklen = env(&quot;CISCO_SPLIT_INC_&quot; + i +<br />
					 &quot;_MASKLEN&quot;);<br />
			run(&quot;route add &quot; + network + &quot; mask &quot; + netmask +<br />
                	     &quot; &quot; + env(&quot;INTERNAL_IP4_ADDRESS&quot;));<br />
		}</p>
<p>	} else {<br />
		echo(&quot;Gateway did not provide network configuration.&quot;);<br />
	}<br />
	echo(&quot;Route configuration done.&quot;);</p>
<p>	if (env(&quot;CISCO_BANNER&quot;)) {<br />
		echo(&quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&quot;);<br />
		echo(env(&quot;CISCO_BANNER&quot;));<br />
		echo(&quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&quot;);<br />
	}	</p>
<p>	break;<br />
case &quot;disconnect&quot;:<br />
 	// Delete direct route for the VPN gateway to avoid<br />
	echo(&quot;Cleaning Routes&#8230;&quot;);</p>
<p>	var gw = getDefaultGatewayOnDisconnect()<br />
	echo(&quot;DefaultGW: &quot; + gw);</p>
<p>	echo(&quot;route delete &quot; + env(&quot;VPNGATEWAY&quot;) + &quot; mask 255.255.255.255&quot;);<br />
	run(&quot;route delete &quot; + env(&quot;VPNGATEWAY&quot;) + &quot; mask 255.255.255.255&quot;);</p>
<p>	echo(&quot;route delete 0.0.0.0  mask 0.0.0.0 &quot;);<br />
	run(&quot;route delete 0.0.0.0  mask 0.0.0.0 &quot;);</p>
<p>	echo(&quot;route add 0.0.0.0  mask 0.0.0.0 &quot; + gw);<br />
	run(&quot;route add 0.0.0.0  mask 0.0.0.0 &quot; + gw);<br />
}</p>
<p>[/js]</p>
</div>
<p style="text-align: right;">
<p style="text-align: right;">
<div>13- Now you should be ready to run the command &#8220;vpnc &#8211;no-detach&#8221;</div>
<p style="text-align: right;">
<div>14- You should be connected to your VPN !</div>
]]></content:encoded>
			<wfw:commentRss>http://www.alessiomolteni.com/2009/10/28/windows-7-64-bit-cisco-vpn-with-cygwin-vpnc-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

