<?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>Phocean.net / Computer Security &#187; Protocols</title>
	<atom:link href="http://www.phocean.net/category/administration-reseau/protocols/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phocean.net</link>
	<description>&#34;A defense that hedgehogs possess is the ability to roll into a tight ball, causing all of the spines to point outwards.&#34; -- Wikipedia</description>
	<lastBuildDate>Wed, 30 Nov 2011 22:02:47 +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>Consider learning LISP</title>
		<link>http://www.phocean.net/2010/07/26/consider-learning-lisp.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=consider-learning-lisp</link>
		<comments>http://www.phocean.net/2010/07/26/consider-learning-lisp.html#comments</comments>
		<pubDate>Sun, 25 Jul 2010 23:54:47 +0000</pubDate>
		<dc:creator>phocean</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[Protocols]]></category>
		<category><![CDATA[BGP]]></category>
		<category><![CDATA[identifier]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[IPv4]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[LISP]]></category>
		<category><![CDATA[locator]]></category>
		<category><![CDATA[Routing]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=899</guid>
		<description><![CDATA[No, not the infamous programming language! But LISP as Location/Identifier Separation Protocol. (I know I am repeating the joke everyone does but I couldn&#8217;t help). But what is it about? It is actually at first difficult to conceive, as we are all so used that IP addresses identify both a person (or a company) and [...]]]></description>
			<content:encoded><![CDATA[<p>No, not the infamous programming language! But LISP as Location/Identifier Separation Protocol. (I know I am repeating the joke everyone does but I couldn&#8217;t help).</p>
<p>But what is it about? It is actually at first difficult to conceive, as we are all so used that <strong>IP addresses identify both a person (or a company) and its location</strong>. It is like this by design because Internet is based on a hierarchical routing model.</p>
<p>What I wrote below is just a bad summary of this <a href="http://www.1-4-5.net/~dmm/lisp/" target="_blank">article by David Meyer</a>. See it as a memo or as a short introduction if you don&#8217;t want to get deep into LISP. Otherwise, jump immediately to the <a title="LISP" href="http://www.1-4-5.net/~dmm/lisp/">original article</a> or to <a href="http://packetlife.net/blog/2010/jul/15/emerging-terminology-lisp-and-trill/" target="_blank">Packetlife</a> which gives some more links.</p>
<p>Now, why would we want to change it? Because with the growing lack of IPv4 free blocks, it became very difficult for the network providers to maintain contiguous blocks. So now the routing tables are bigger than they should be and not optimized. Customers want multihomming and mobility, while providers want to limit the routing overload. Two different point of views which can&#8217;t be satisfied with the hierarchical routing of today. BGP partially addresses some of these issues, but it has limits and <a title="BGP blackhole" href="http://arstechnica.com/old/content/2008/02/insecure-routing-redirects-youtube-to-pakistan.ars" target="_blank">misconfigurations</a> with deep impacts (eg blackholes) happen regularly. Note that IPv6 can&#8217;t be of any help in this case.</p>
<p>But LISP tries. And in a nice way, as it is totally transparent to the end-users. Only the core network of the providers are impacted.</p>
<p>Basically, the customer IP stack remains untouched during the transit. <strong>With LISP, the customer IP address is only the identifier</strong>,<strong> no more the locator.</strong></p>
<p>Then, LISP add a new IP stack on routers configured by the provider. These routers, named ITR (Ingress Tunnel Router) and ETR (Egress Tunnel Router) according to the direction of the flow, encapsulate the packets with the new IP stack with their own address as origin. A little bit as a proxy but at a lower level, their purpose is to route the packets on behalf of the customer.</p>
<p>In short, <strong>the role of an ITR is to find the appropriate ETR for the destination</strong>, to route the packet correctly. LISP comes with <strong>a directory used for the ETR lookup</strong>. The directory is supposed to be &#8220;manually&#8221; maintained by the provider (the overload should be acceptable because we are in a core network, where changes in topology don&#8217;t happen all the time). Now that the ITR knows what the location for the recipient is, it sends out the packet with the E<strong>TR as destination IP</strong>. The way back works just the same.</p>
<p>Between the ITR and the ETR, of course, there can be a number of different providers and routers, not supporting LISP, the routing part being handled by classic routing protocoles like BGP.</p>
<p>You should see clearly now the beauty of LISP : if a customer moves with his IP block, for the provider it is just a matter of updating the location within the LISP directory. There are also some great features like support of load balancing in the case of multi-homing . LISP appears to be efficient and straightforward, but n<a title="IETF - LISP" href="https://datatracker.ietf.org/doc/draft-ietf-lisp/" target="_blank">ot yet validated by the IETF</a>. Keep an eye on this work in progress!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phocean.net/2010/07/26/consider-learning-lisp.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPv6 tunneling and security</title>
		<link>http://www.phocean.net/2009/11/04/ipv6-tunneling-and-security.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ipv6-tunneling-and-security</link>
		<comments>http://www.phocean.net/2009/11/04/ipv6-tunneling-and-security.html#comments</comments>
		<pubDate>Wed, 04 Nov 2009 10:11:41 +0000</pubDate>
		<dc:creator>phocean</dc:creator>
				<category><![CDATA[Defense]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Protocols]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[6to4]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Teredo]]></category>
		<category><![CDATA[tunneling]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=492</guid>
		<description><![CDATA[Interesting article to read about IPv6 tunneling and security aspects. The commends are worth reading too. Follow this link.]]></description>
			<content:encoded><![CDATA[<p>Interesting article to read about IPv6 tunneling and security aspects. The commends are worth reading too.</p>
<p>Follow <a title="IPv6 tunneling and security" href="http://blog.trendmicro.com/ipv6-tunneling-protocols-good-for-adoption-not-so-hot-for-security/">this link</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phocean.net/2009/11/04/ipv6-tunneling-and-security.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to network attacks : Physical Layer</title>
		<link>http://www.phocean.net/2008/08/24/introduction-to-network-attacks-physical-layer.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introduction-to-network-attacks-physical-layer</link>
		<comments>http://www.phocean.net/2008/08/24/introduction-to-network-attacks-physical-layer.html#comments</comments>
		<pubDate>Sun, 24 Aug 2008 12:36:05 +0000</pubDate>
		<dc:creator>phocean</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Protocols]]></category>
		<category><![CDATA[aircrack-ng]]></category>
		<category><![CDATA[arp]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[physical layer]]></category>
		<category><![CDATA[spoofing]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=207</guid>
		<description><![CDATA[That will be a short article, mainly because of two things. First, some methods are beyond my knowledge, involving electronics or hardware manipulation. Second, such methods are not efficient compare to higher level ones, and so rarely used. The mere concept of a physical attack implies that you have a direct physical access to your [...]]]></description>
			<content:encoded><![CDATA[<p>That will be a short article, mainly because of two things. First, some methods are beyond my knowledge, involving electronics or hardware manipulation. Second, such methods are not efficient compare to higher level ones, and so rarely used.</p>
<p>The mere concept of a physical attack implies that you have a direct physical access to your target, giving you the ability to modify it as you wish.<br />
This is an ideal situation for an attacker, not quite common. And in that case, there is nothing much to be done on the defensive side.</p>
<p><span id="more-207"></span></p>
<p>It is one of the reason why, as a computer security enginneer, a lot of attention must be always payed on the physical security : access to the machine in a locked room, identification of the persons entering with an electronic card, etc.<br />
Without it, the best security software setting is useless.</p>
<p>There can be many way to implement a physical layer attack : modifying the firmware of a router at the maker itself, plug an electronic sniffer on a network segment, inserting a hub, etc.</p>
<p>Attacks on wireless networks are the most popular and easy to do, because of the nature itself of wifi.<br />
Check at the man of <a href="http://www.aircrack-ng.org/doku.php" target="_blank">aircrack-ng</a> or one of the numerous wifi craking tutorial on the Net if by any chance you were not aware of it.</p>
<p>Another kind of attacks, that can be done without interfering directly with the hardware, concern the MAC address manipulation.</p>
<p>The MAC address is the &#8220;physical&#8221; way to identify a machine on the network. This address, supposedly unique world-wide, is set by the network card maker.<br />
It is coded with 48 bits, generally on a read-only chip (ROM) to ensure that it can&#8217;t be modified. In reality, all operating systems allow to override this value at a logical level (as seen by the network stack of the system).</p>
<p>On Windows XP, changing the MAC address of a network card is as easy as going in the advanced properties of the network card driver, changing the value and deactivating / reactivating the network card.</p>
<div id="attachment_211" class="wp-caption aligncenter" style="width: 449px"><a href="http://www.phocean.net/wp-content/uploads/2008/08/windows-mac.png"><img class="size-full wp-image-211" title="windows-mac" src="http://www.phocean.net/wp-content/uploads/2008/08/windows-mac.png" alt="Changing the MAC address on Windows" width="439" height="458" /></a><p class="wp-caption-text">Changing the MAC address on Windows</p></div>
<p>In case it does not work (it depends on the driver), there is a free specific tool : <a title="Macshift" href="http://devices.natetrue.com/macshift/" target="_blank">Macshift</a>.</p>
<p>On GNU/Linux, it is even easier. Just fire up these two commands :</p>
<pre lang="bash">$ ifconfig eth1 down hw ether 00:00:00:00:00:01
$ ifconfig eth1 up</pre>
<p>As you can see, the MAC address really cannot be considered as reliable way of identification.</p>
<p>At last, the MAC duplicating attack consists in using on the hostile node the same MAC address as an active machine of the same network.<br />
A basic or unprotected switch will see the same MAC address coming from two different ports and transfer the packets to both.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phocean.net/2008/08/24/introduction-to-network-attacks-physical-layer.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FTP configuration issues</title>
		<link>http://www.phocean.net/2007/11/02/the-horror-of-ftp-and-cisco-firewall.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-horror-of-ftp-and-cisco-firewall</link>
		<comments>http://www.phocean.net/2007/11/02/the-horror-of-ftp-and-cisco-firewall.html#comments</comments>
		<pubDate>Fri, 02 Nov 2007 15:10:28 +0000</pubDate>
		<dc:creator>phocean</dc:creator>
				<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Firewalling]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Protocols]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Asa]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Pix]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=80</guid>
		<description><![CDATA[I found that it was a real mess to set up a FTP server in a DMZ, behind a firewall Cisco Asa (501 model with IOS version 7.0). The FTP server is on the DMZ area, and therefore I natted a public IP to the private IP in the DMZ subnet of this server. Doing [...]]]></description>
			<content:encoded><![CDATA[<p>I found that it was a real mess to set up a FTP server in a DMZ, behind a firewall Cisco Asa (501 model with IOS version 7.0).</p>
<p>The FTP server is on the DMZ area, and therefore I natted a public IP to the private IP in the DMZ subnet of this server.</p>
<pre class="brush: plain; title: ; notranslate">static (dmz,outside) &lt;public IP&gt; &lt;private_IP&gt; netmask 255.255.255.255</pre>
<p>Doing so, I expect that my FTP server (like Vsftpd on Linux) to be reachable within its public IP, from the Asa external interface.<br />
<span id="more-80"></span><br />
<strong>Choosing a FTP transfer mode </strong></p>
<p>Before going further, let&#8217;s recall the two modes in which the FTP protocol can work :</p>
<ul>
<li>active mode : this is the historical mode, but should be considered obsolete now because of the numerous issues it contains. In this mode, after the client initiate the communication on the port 21 (command chanel), the server initiate the data transfert chanel from its port 20 toward a port specified by the client. It causes two big problems :
<ul>
<li>the client must configure its firewaling to allow incomming traffic on this port. In the real life, this is most likely to be like allowing the 1024-65535 range port for incoming traffic. Not really secure, isn&#8217;t it ?</li>
<li>if the client is behind a NAT, it won&#8217;t work ! As the server initiate the connection, the router does not have any entry for the flow in its NAT table. It will just drop the connexion.</li>
</ul>
</li>
<li>passive mode : the difference here is that the server chooses on what port the data transfert will be operated. The port is given to the client when this one initiate the communication. Actually, the server never initiate any connexion, so the name &#8220;passive&#8221;. The only thing to do on the server side is to set the right firewall rule to allow the server ports. The client then initiate the transfert on the given port. It solves the client side firewalling problem, because the firewall will see it as outbound traffic. With correct rules, especially if the firewall is statefull, this is an easy thing.</li>
</ul>
<p><strong>Configuring the passive mode on the server </strong></p>
<p>So, is the passive mode the end of all problems ?</p>
<p>Not yet&#8230;</p>
<p>By default, the FTP server will be listening on its netword interface and answer to the FTP requests with its private IP, if, like probably in many case, the FTP server is located on a DMZ network.</p>
<p>In such a case, the client gets a private IP to connect with&#8230; and can never reach the server properly.</p>
<p>To workaround this problem, most of FTP servers can be configured to answer with there public IP.</p>
<p>With VSFTP, this is a line like :</p>
<pre class="brush: plain; title: ; notranslate">pasv_address = $public_IP</pre>
<p>There another two issues for that :</p>
<ul>
<li>the server won&#8217;t be reachable anymore within its private IP, for instance from the local subnet</li>
<li>the Cisco Asa firewall drops the traffic</li>
</ul>
<p><strong>Cisco Asa issue </strong></p>
<p>The Asa log file shows :</p>
<pre class="brush: plain; title: ; notranslate">FTP port command different address: $IP_addr ($IP_addr2) to $IP_addr_3 on interface int_name</pre>
<p>The explanation from the cisco website :<br />
<em>A client issued an FTP port command and supplied an address other than the address used in the connection. This error message is indicative</em></p>
<p><em>of an attempt to avert the site&#8217;s security policy. For example, one might attempt to hijack an FTP session by changing the packet on the way, and putting</em></p>
<p><em>different source information instead of the correct source information. The PIX Firewall drops the packet, terminates the connection, and logs the event.</em></p>
<p><em>In the error message displayed, the IP address in parentheses is the address from the PORT command.</em><br />
Well, as there is nothing to do against this behaviour, I won&#8217;t use the pasv_address option.</p>
<p><strong>Private IP issue</strong></p>
<p>So, for now we stick with a server sending its private IP address in any case. That solves any issue in the local subnet, but is it possible to do anything for external clients which needs to get a public IP ?</p>
<p>Actually, and this is really not a satisfying answer, it depends on the client. Most of the FTP client must have the some options to workaround this issue, but not all.</p>
<p>Let&#8217;s check how it is with a few FTP clients.<br />
<em><strong><br />
<em> Basic FTP command line client (Linux)</em></strong></em></p>
<pre class="brush: plain; title: ; notranslate">$ ftp X.X.X.X
ftp&gt; dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-rw-r--    1 102      1001           21 Aug 16 10:53 test
226 Directory send OK.</pre>
<p>Humm&#8230; it is working, but it shouldn&#8217;t as my server is configured for passive mode.</p>
<p>Let&#8217;s see what is going on with Wireshark&#8230; Two packets are interesting :</p>
<pre class="brush: plain; title: ; notranslate">28    35    192.168.1.2    X.X.X.X   FTP    Request: PORT 192,168,1,2,173,87
29    36    X.X.X.X    192.168.1.2    FTP    Response: 200 PORT command successful. Consider using PASV.</pre>
<p>From the client, we have a PORT request, which shows that our client is connecting in active mode.</p>
<p>Surprise, the server replies ! And says successful, even if the IP given is a private one. That should not work and, if any response, not go out of the external firewall&#8230;<br />
<strong>Note</strong> : (192,168,1,2,173,87) is the FTP way to manage IPs and port. The IP is simply given by the four first numbers : 192,168,1,2 &lt;=&gt; 192.168.1.2.<br />
The 2 last ones gives you the port number with this formula : 173,87 =&gt; 173 x 256 + 87 = port n°44375<br />
Anyway, let&#8217;s try the passive mode :</p>
<pre class="brush: plain; title: ; notranslate">ftp&gt; passive on
Passive mode on.
ftp&gt; dir
227 Entering Passive Mode (10,1,1,1,15,195)
receive aborted
waiting for remote to finish abort</pre>
<p>We tried to switch to passive mode. The server gaves its IP, but its private one (192.168.10.1). The client trying to reach this address can&#8217;t and falls in timeout (I killed it, no more patience <img src='http://www.phocean.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) .</p>
<p>Now, let&#8217;s summarize.<br />
Using the ftp basic client, we can&#8217;t go through in passive mode. We get a private IP and we have no workaround.<br />
The active mode works, but it is thanks to the behaviour of VSFTP.</p>
<p>A look on the man page of VSFTP gives some answers : the</p>
<pre class="brush: plain; title: ; notranslate">port_enable</pre>
<p>directive, set to YES by default, allow the PORT command from the client even in passive mode. So, we could add in the vsftd.conf configuration file :</p>
<pre class="brush: plain; title: ; notranslate">port_enable=NO</pre>
<p>After that the server will answer</p>
<pre class="brush: plain; title: ; notranslate">550 Permission denied</pre>
<p>when a PORT command is issued. At the end, I won&#8217;t set this, because such a behaviour is actually nice.</p>
<p>I still wonder how VSFTP could get the public IP when the PORT command send the private IP. I guess, and it would be a smart behaviour, that the program checks the underlying protocol layers and takes the right IP from the IP header&#8230; I will have it confirmed and update this post.</p>
<p><em><em><strong>Gftp</strong></em></em></p>
<p>This Gnome FTP client behave like the ftp command line client in passive mode : it falls into timeout.</p>
<p>It doesn&#8217;t try by default to fail over active mode.</p>
<p>You can configure either active mode or ignoring the passive command IP in the options :</p>
<p><em><a title="gftp - ftp connexion parameters" href="http://www.phocean.net/wp-content/uploads/2007/11/gftp-pasv.png"><img src="http://www.phocean.net/wp-content/uploads/2007/11/gftp-pasv.thumbnail.png" alt="gftp - ftp connexion parameters" /></a></em></p>
<p><em><em><strong>Filezilla</strong></em></em></p>
<p>Filezilla has the most interesting behaviour. When the standard passive mode fails, it is able to fail over by using active mode or using the public IP seen from the server.</p>
<p>This can be configured in the connexion options :</p>
<p><em><a title="filezilla connexion parameters" href="http://www.phocean.net/wp-content/uploads/2007/11/filezilla.png"><img src="http://www.phocean.net/wp-content/uploads/2007/11/filezilla.thumbnail.png" alt="filezilla connexion parameters" /></a></em></p>
<p>When Filezilla uses the public IP address instead of the transmitted one :</p>
<pre class="brush: plain; title: ; notranslate"> PASV
227 Entering Passive Mode (10,1,1,1,15,209)
LIST
150 Here comes the directory listing.
226 Directory send OK.</pre>
<p>When it is configured to switch to active mode :</p>
<pre class="brush: plain; title: ; notranslate">PASV
227 Entering Passive Mode (10,1,1,1,15,179)
PORT 192,168,1,2,130,1
200 PORT command successful. Consider using PASV.
LIST
150 Here comes the directory listing.
226 Directory send OK.</pre>
<p><strong>Conclusion</strong></p>
<p>I could not reach the point where I can be 100% sure that it will work in all configurations. The best I could do is a series of small fixes to get the best compromise as possible.</p>
<p>I guess that using VSFTD as a server and recomanding a good client as Filezilla will work pretty well &#8211; and that won&#8217;t be a big deal to get to such a configuration.</p>
<p>If anyone has some better ideas, or see I fooled somewhere before my conclusion, please let me know.</p>
<p>But anyway, really, FTP sucks. It is anoying that the use of this protocol is still required by some companies.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phocean.net/2007/11/02/the-horror-of-ftp-and-cisco-firewall.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Perl : how to monitor a service remotely using sockets</title>
		<link>http://www.phocean.net/2007/07/15/perl-how-to-monitor-a-service-remotely-using-sockets.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=perl-how-to-monitor-a-service-remotely-using-sockets</link>
		<comments>http://www.phocean.net/2007/07/15/perl-how-to-monitor-a-service-remotely-using-sockets.html#comments</comments>
		<pubDate>Sun, 15 Jul 2007 17:59:55 +0000</pubDate>
		<dc:creator>phocean</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Protocols]]></category>
		<category><![CDATA[IPSEC]]></category>
		<category><![CDATA[Isakmpd]]></category>
		<category><![CDATA[IsakmpdMon]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=64</guid>
		<description><![CDATA[I came to program my first Perl script based on sockets, after setting an IPSEC tunnel.

This tunnel is linking the remote peer and the local peer through an OpenBSD VPN gateway (managed with Isakmp).

The problem is that this connection is limited time, for access right reason. So it is not a 24 hours standard tunnel, but rather an on-demand type connection.

Note that the connection is automatically reseted by the remote peer, by invaliding the cookie of the connection and therefore obliging to renegotiate the VPN tunnel from the beginning : phase 1 of the key exchange.

In one word, the Isakmp service has to be restarted every time we need the tunnel to be up.

Of course, this is not the purpose of Isakmp to have such a mecanism and what is interesting is to start the tunnel from the local peer, every time it needs to do some transfer.

The graph below summarizes the situation :

IPSEC tunnel with OpenBSD as a VPN gateway

That why I came to develop a script that listen on a socket and allow that peer to remotely restart the Isakmp service.]]></description>
			<content:encoded><![CDATA[<p>I came to program my first Perl script based on sockets, after setting an IPSEC tunnel.</p>
<p>This tunnel is linking the remote peer and the local peer through an OpenBSD VPN gateway (managed with Isakmp).</p>
<p>The problem is that time allowed for this connection is limited, for security policy reasons. So it is not a 24- hour standard tunnel, but rather an on-demand type connection.</p>
<p>Note that the connection is automatically reset by the remote peer, by invalidating the connection cookie and therefore oblige to renegotiate the VPN tunnel from the beginning (phase 1 of the key exchange).</p>
<p>In other words, the Isakmp service has to be restarted every time we need the tunnel to be up.</p>
<p>Of course, it is not the purpose of Isakmp to have such a mechanism and what we want is to start the tunnel from the local peer, every time it needs to do some transfer.</p>
<p>The graph below summarizes the situation :</p>
<p style="text-align: center;"><img src="http://www.phocean.net/wp-content/uploads/2007/07/ipsec-tunnel.png" alt="IPSEC tunnel with OpenBSD as a VPN gateway" /></p>
<p>That is why I came to develop a script that opens a socket and allows the peer to remotely restart the Isakmp service.</p>
<p><span id="more-64"></span></p>
<p>Perl is once again the perfect language for someone like me, who is not a developer. My script uses mainly 2 CPAN modules : <a title="NetServer::generic" href="http://http://search.cpan.org/~chstross/NetServer-Generic-1.03/Generic.pm" target="_blank">NetServer::Generic</a> to manage the socket and <a title="Proc::ProcessTable" href="http://search.cpan.org/~durist/Proc-ProcessTable-0.41/ProcessTable.pm" target="_blank">Proc::ProcessTable</a> to get the PID of a running process.</p>
<p>You can dowload it here : <strong><a title="IsakmpdMon" href="http://www.phocean.net/wp-content/uploads/2007/07/isakmpdmon.zip">IsakmpdMon</a></strong>.</p>
<p>And here is the documentation on how to use it : <a title="IsakmpdMon Synopsys" href="http://www.phocean.net/wp-content/uploads/2007/07/isakmpdmon.html"><strong>IsakmpdMon Synopsys</strong>.</a></p>
<p><strong>ATTENTION</strong> : for security reason, only trusted IPs should be allowed to send the commands.</p>
<p>To have your commands accepted, edit the line :</p>
<pre class="brush: perl; title: ; notranslate">my ($allowed) = ['10\.80\.1\.2'];</pre>
<p>with your IPs. It can be a list of IPs or hostnames separated by commas. You can use some jockers (*) for the names. Please refer to the <a title="NetServer::generic" href="http://http://search.cpan.org/~chstross/NetServer-Generic-1.03/Generic.pm" target="_blank">NetServer::Generic</a> documentation for more info.</p>
<p>Note that this script can be adapted to any usage to manage all kinds of services remotely&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phocean.net/2007/07/15/perl-how-to-monitor-a-service-remotely-using-sockets.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVPN and DNS on a linux client</title>
		<link>http://www.phocean.net/2006/12/07/openvpn-and-dns-on-a-linux-client.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openvpn-and-dns-on-a-linux-client</link>
		<comments>http://www.phocean.net/2006/12/07/openvpn-and-dns-on-a-linux-client.html#comments</comments>
		<pubDate>Thu, 07 Dec 2006 16:42:00 +0000</pubDate>
		<dc:creator>phocean</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Cisco]]></category>
		<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Protocols]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[OpenVPN]]></category>

		<guid isPermaLink="false">http://192.168.1.10/wordpress/?p=12</guid>
		<description><![CDATA[<p>I got a weired issue with Linux clients while it worked fine with Windows machines. For some reason, the /etc/resolv.conf did not get updated.</p> <p>I found out a workaround thanks to <a hreflang="en" href="http://www.smop.co.uk/node/69">this page</a>.</p> Of course, your server configuration file must contain (if 192.168.1.1 is your DNS server):<br /><blockquote><p><code>push &#34;dhcp-option DNS 192.168.1.1&#34;</code></p> </blockquote><br />]]></description>
			<content:encoded><![CDATA[<p>I got a weired issue with Linux clients while it worked fine with Windows machines. For some reason, the /etc/resolv.conf did not get updated.  I found out a workaround thanks to <a hreflang="en" href="http://www.smop.co.uk/node/69">this page</a>.  Of course, your server configuration file must contain (if 192.168.1.1 is your DNS server):</p>
<pre class="brush: plain; title: ; notranslate">push &quot;dhcp-option DNS 192.168.1.1&quot;</pre>
<p><span id="more-12"></span> First, you will need the resolvconf program. In debian :</p>
<pre class="brush: plain; title: ; notranslate">$ apt-get install resolvconf</pre>
<p>Then, you will need to add these lines into the configuration file of your Linux client (let&#8217;s say /etc/openvpn/client.conf) : </p>
<pre class="brush: plain; title: ; notranslate">up /etc/openvpn/domain.up plugin /usr/lib/openvpn/openvpn-down-root.so /etc/openvpn/domain.down</pre>
<p>The plugin provided by OpenVpn gives back root privilege (when initialized, OpenVPN needs root access but drops it soon).<br />
Now let&#8217;s create the scripts :  </p>
<p><strong>/etc/openvpn/domain.up</strong> : </p>
<pre class="brush: bash; title: ; notranslate"> #!/bin/sh
    # really naff script to add nameserver entry on up
    DEV=$1
    set | sed -n &quot;      s/^foreign_option_.* DNS \(.*\)'/nameserver \1/; T next; p;
    :next; s/^foreign_option_.* DOMAIN \(.*\)'/domain \1/; T; p;
      &quot; | resolvconf -a $DEV
    resolvconf -u</pre>
<p><strong>/etc/openvpn/domain.dow</strong>n : </p>
<pre class="brush: bash; title: ; notranslate"> #!/bin/sh
  # really naff script to delete nameserver entry on down
  DEV=$1
  resolvconf -d $DEV
  resolvconf -u</pre>
<p>Now let&#8217;s give them the suitable rights :</p>
<pre class="brush: plain; title: ; notranslate">$ chmod +x domain*</pre>
<p>Finally, just restart openvpn and that should be fine !</p>
<p><strong>UPDATE</strong> <strong>2008/07/11</strong> : The two scripts above are kind of obsolete, because, at least in Debian Etch, a similar script is included in the OpenVPN package.</p>
<p>There it is :</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
#
# Parses DHCP options from openvpn to update resolv.conf
# To use set as 'up' and 'down' script in your openvpn *.conf:
# up /etc/openvpn/update-resolv-conf
# down /etc/openvpn/update-resolv-conf
#
# Used snippets of resolvconf script by Thomas Hood &lt;jdthood@yahoo.co.uk&gt;
# and Chris Hanson
# Licensed under the GNU GPL.  See /usr/share/common-licenses/GPL.
#
# 05/2006 chlauber@bnc.ch
#
# Example envs set from openvpn:
# foreign_option_1='dhcp-option DNS 193.43.27.132'
# foreign_option_2='dhcp-option DNS 193.43.27.133'
# foreign_option_3='dhcp-option DOMAIN be.bnc.ch'

[ -x /sbin/resolvconf ] || exit 0

case $script_type in

up)
	for optionname in ${!foreign_option_*} ; do
		option=&quot;${!optionname}&quot;
		echo $option
		part1=$(echo &quot;$option&quot; | cut -d &quot; &quot; -f 1)
		if [ &quot;$part1&quot; == &quot;dhcp-option&quot; ] ; then
			part2=$(echo &quot;$option&quot; | cut -d &quot; &quot; -f 2)
			part3=$(echo &quot;$option&quot; | cut -d &quot; &quot; -f 3)
			if [ &quot;$part2&quot; == &quot;DNS&quot; ] ; then
				IF_DNS_NAMESERVERS=&quot;$IF_DNS_NAMESERVERS $part3&quot;
			fi
			if [ &quot;$part2&quot; == &quot;DOMAIN&quot; ] ; then
				IF_DNS_SEARCH=&quot;$part3&quot;
			fi
		fi
	done
	R=&quot;&quot;
	if [ &quot;$IF_DNS_SEARCH&quot; ] ; then
        	R=&quot;${R}search $IF_DNS_SEARCH&quot;
	fi
	for NS in $IF_DNS_NAMESERVERS ; do
        	R=&quot;${R}nameserver $NS&quot;
	done
	echo -n &quot;$R&quot; | /sbin/resolvconf -a &quot;${dev}.inet&quot;
	;;
down)
	/sbin/resolvconf -d &quot;${dev}.inet&quot;
	;;
esac
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.phocean.net/2006/12/07/openvpn-and-dns-on-a-linux-client.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

