<?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>Aptivate &#124; A Blog for ICT4D &#187; security</title>
	<atom:link href="http://blog.aptivate.org/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.aptivate.org</link>
	<description>International I.T. Development</description>
	<lastBuildDate>Wed, 01 Feb 2012 14:09:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.6</generator>
		<item>
		<title>Simple Cisco VPN How-To</title>
		<link>http://blog.aptivate.org/2010/08/03/simple-cisco-vpn-how-to/</link>
		<comments>http://blog.aptivate.org/2010/08/03/simple-cisco-vpn-how-to/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 21:24:42 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Engineer's Log]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=605</guid>
		<description><![CDATA[One of our fellow Humanitarian Centre organisations, Engineers Without Borders UK (EWB), asked for our help in setting up a virtual private network (VPN), so that their remote workers can access their file server. This is something that ought to be really simple. It&#8217;s probably the most common use case of VPNs, Windows has a [...]]]></description>
			<content:encoded><![CDATA[<p>One of our fellow <a href="http://www.humcentre.org">Humanitarian Centre</a> organisations, <a href="http://www.ewb-uk.org">Engineers Without Borders UK</a> (EWB), asked for our help in setting up a virtual private network (VPN), so that their remote workers can access their file server.</p>
<p>This is something that ought to be really simple. It&#8217;s probably the most common use case of VPNs, Windows has a built-in VPN client, and Cisco routers can be used as VPN servers. EWB want it to be simple, because they have non-technical remote workers. It turned out to be much harder and take much longer than I expected.</p>
<h3>Information Overload</h3>
<p>One of the biggest problems was the lack of useful information, and the profusion of useless. The information fell mainly into four categories:</p>
<ul>
<li>Cisco marketing materials touting the benefits of VPNs and their expensive Concentrator and WebVPN products;</li>
<li>Cisco knowledge base articles describing the setup of complex VPN scenarios;</li>
<li>Cisco command references with little or no details on what each command actually does, or how to use them together;</li>
<li>Cisco exam study sites with inaccurate, out-of-date or cookie-cutter command sequences, with even less explanation of what the commands actually do.</li>
</ul>
<p>Because I couldn&#8217;t find what I was looking for, and had to work it out the hard way, I&#8217;ve written it up in the hope that it will help others.</p>
<p>I would recommend any organisations that simply want to share files to seriously consider a file-sharing service like <a href="http://dropbox.com">DropBox</a> or raw <a href="http://s3.amazonaws.com">Amazon S3</a> instead of a local file server and VPN. In many cases the low upload bandwidth of ADSL connections, combined with internal office use of the connection. will make a VPN impractically slow, especially compared to Amazon&#8217;s unlimited upload and download bandwidth. But EWB already had the file server and they just wanted to access it remotely, not to change how they work.</p>
<p>Our scenario is simple: an internal office network with private IP addresses, a Cisco 1800 router providing ADSL connectivity for the office, and remote field workers running Windows desktops.</p>
<h3>Getting the Client</h3>
<p>For simplicity, we and EWB had hoped to use the built-in VPN client on Windows, which would remove the need to download and install software on the remote workers&#8217; machines. But unfortunately the Cisco 1800 does not support this. Windows uses L2TP over IPSEC for modern, secure VPNs, as a replacement for the old insecure PPTP protocol. But Cisco has crippled the L2TP support in this router, and it only supports raw IPSEC. Only their more expensive routers support serving L2TP over IPSEC, allowing simple direct connections from Windows.</p>
<p>Raw IPSEC is the only remaining option on this router, but it&#8217;s difficult to configure due to its complexity, and the number of choices that need to be made. The standard requires both sides to have the same settings configured, but provides no way to do this automatically. Manual configuration would make life very hard for the remote workers. To solve this problem, Cisco has a non-standard protocol for auto-configuration of the clients:</p>
<blockquote><p>
Establishing a VPN connection between two routers can be complicated, and it typically requires tedious coordination between network administrators to configure the two routers&#8217; VPN parameters.</p>
<p>The Cisco Easy VPN Client feature eliminates much of this tedious work by implementing Cisco&#8217;s Unity Client protocol, which allows most VPN parameters to be defined at [the] IPSec server. </p>
<p><a href="http://www.cisco.com/en/US/products/hw/routers/ps221/prod_configuration_guide09186a008007cfa7.html#wp101952">Cisco Easy VPN Client for the Cisco 1700 Series Routers</a>
</p></blockquote>
<p>So we needed to find a replacement client that was easy to use and could talk to the Cisco. Preferably a free one.</p>
<p>Then we discovered that although Cisco&#8217;s own VPN client is technically free, you can&#8217;t actually download it without a support contract, which neither we nor EWB have.</p>
<p>In the end we found that if you go to Cisco&#8217;s <a href="http://tools.cisco.com/support/downloads/pub/ImageList.x?relVer=5.0.07.0290&#038;mdfid=281940730&#038;sftType=VPN+Client+Software&#038;optPlat=Windows&#038;nodecount=2&#038;edesignator=null&#038;modelName=Cisco+VPN+Client+v5.x&#038;treeMdfId=268438162&#038;treeName=Security&#038;modifmdfid=&#038;imname=&#038;hybrid=&#038;imst=&#038;lr=Y">VPN client software page</a>, find the filename of the latest version of the client, and Google it, you&#8217;ll find that <a href="http://www.google.co.uk/search?q=vpnclient-win-msi-5.0.07.0290-k9.exe&#038;ie=utf-8&#038;oe=utf-8&#038;aq=t&#038;rls=com.ubuntu:en-GB:unofficial&#038;client=firefox-a">several people</a> have had enough of this nonsense and posted the client online, so it can be downloaded.</p>
<p>Of course it&#8217;s important to be aware of the potential for viruses in copies that you download from random sites on the Internet, as well as fake download sites that lead you around in circles of free registrations, credit card details and pop-up porn adverts. <a href="http://samsten.net/work/cvpnc/">This site</a> worked fine for me, but it may have been taken down by Cisco&#8217;s attack dogs by the time you read this.</p>
<h3>Security with Obscurity</h3>
<p>We decided to choose a configuration that trades some security for ease of use. So instead of authenticating with certificates, we used pre-shared keys. The VPN server has its own login system anyway, which provides an additional layer of security once the remote user is connected to the VPN.</p>
<h3>Names and Addresses</h3>
<p>Connecting clients need to be allocated an IP address to use over the VPN. We could have used public IPs, or private IPs in the same subnet (with <a href="http://www.ciscocatalyst.info/en/US/docs/ios/ipaddr/command/reference/iad_arp.html#wp1013235">proxy ARP</a>), but we chose to use private IPs in a different subnet. This makes the routing easier, as clients and local network servers will know that they have to route the traffic via the router anyway, and it allows EWB to implement stricter network access policies for VPN clients, if they wish. </p>
<p>We needed to create a local pool (not a DHCP pool) to draw these addresses from:</p>
<pre>
ip local pool vpnpool 192.168.2.100 192.168.2.200
</pre>
<h3>Keys to the Kingdom</h3>
<p>We created an ISAKMP (IKE) policy to specify the authentication method and the level of encryption to be used for negotiation of IPSEC Security Associations (SAs). We chose to make this the first, highest priority policy, and to use AES-256 encryption (strong and fast), Group 2 (1024-bit) Diffie-Hellman key exchange, and pre-shared keys for client authentication as noted above:</p>
<pre>
crypto isakmp policy 1
 encr aes 256
 authentication pre-share
 group 2
</pre>
<p>Then we specified the pre-shared key itself. This is the only thing that stops random clients on the Internet from connecting to your local network, so it&#8217;s even more important than a strong wireless network key. Of course this is not the real key:</p>
<pre>
crypto isakmp key ThisKeyMustBeKeptSecret address 0.0.0.0 0.0.0.0
</pre>
<p> We specify that any IP address can use it by using the wildcard address, <code>0.0.0.0 0.0.0.0</code>.</p>
<h3>At the End of the Tunnel</h3>
<p>It seems to be common in corporate environments that, when a user is connected to a VPN, all of their Internet traffic is routed through the VPN. It certainly makes it easier for the network administrators, as they don&#8217;t have to define specific routes for the tunnel, but it wastes their bandwidth and makes Internet access much slower for the remote workers, so we decided not to do this.</p>
<p>Just routing a single subnet through a tunnel is called a <em>split tunnel</em>. I couldn&#8217;t find simple documentation on setting it up, so I used the <a href="http://www.cisco.com/en/US/docs/ios/sec_secure_connectivity/configuration/guide/sec_easy_vpn_rem.html#wp1060585">Cisco Easy VPN Remote example</a>, extracting just the bits we needed to route only the 192.168.1.0/24 subnet through the tunnel.</p>
<p>First we have to create an access control list (ACL) that defines, on the local (source address) side, what traffic clients should route into the tunnel:</p>
<pre>
ip access-list extended ewb_office_split_tunnel
 remark Defines which local (office) networks a remote VPN client will route to
 permit ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
</pre>
<p>I&#8217;m not sure if the second half of the ACL is actually necessary. It doesn&#8217;t appear to make any difference if I specify <code>any</code> instead of <code>192.168.2.0 0.0.0.255</code>.</p>
<h3>Client Configuration</h3>
<p>We use Cisco&#8217;s EzVPN (Unity) protocol, as described earlier, to configure connecting clients automatically. To do this, we have to tell the server what configuration should be sent to clients when they connect:</p>
<pre>
crypto isakmp client configuration group EWB
 key ThisKeyMustBeKeptSecret
 dns 192.168.1.1
 wins 192.168.1.2
 pool vpnpool
 acl ewb_office_split_tunnel
 netmask 255.255.255.0
</pre>
<p>A little explanation about what these options do:</p>
<dl>
<dt>crypto isakmp client configuration group [name]</dt>
<dd>The <em>name</em> must match the <strong>group name</strong> that the client uses when it connects. This is how the server decides which configuration to send to the client.</dd>
<dt>key</dt>
<dd>For some reason the client needs to be told what key to use, even though it&#8217;s already been entered by the user, and the client knows it because it wouldn&#8217;t be able to get this far in the negotiation without it!
</dd>
<dt>dns</dt>
<dd>Tells the client which DNS server to use, for resolving local (private) hostnames, or resolving inside the split horizon. You can specify a second DNS server after the primary one. You probably only need this if you&#8217;re running a Windows domain, in which case it should point to the domain controller, or if you have split horizon DNS.</dd>
<dt>wins</dt>
<dd>Tells the client which WINS server to use, for resolving local SMB server names. Again, you probably only need this if you&#8217;re running a Windows domain, in which case it should also point to the domain controller.</dd>
<dt>pool</dt>
<dd>Tells the server which local pool (not DHCP pool) to assign the client&#8217;s address from. You can specify any name here, even a pool that doesn&#8217;t exist, but clients won&#8217;t be able to connect unless the pool name is a valid local pool.</dd>
<dt>acl</dt>
<dd>This ACL, which we defined earlier, is used to tell the clients which subnets are reachable through the connection (split tunnel mode). If no <strong>acl</strong> statement is used, the tunnel is not split, and a default route is set through the VPN tunnel instead.</dd>
<dt>netmask</dt>
<dd>Defines the network mask that the client will apply to its client interface, in combination with the IP address assigned from the pool.</dd>
</dl>
<h3>Profiling</h3>
<p>Next, we create an ISAKMP profile on the server which tells the server to assign IP addresses automatically, and which <a href="http://www.cisco.com/en/US/docs/ios/12_2/dial/configuration/guide/dafvrtmp.html#wp1000958">virtual template</a> to use when creating the virtual-access interfaces for the server side of the tunnel. We haven&#8217;t defined the virtual template yet, but we will in a second.</p>
<pre>
crypto isakmp profile ewb_isakmp_profile
   match identity group EWB
   isakmp authorization list sdm_vpn_group_ml_4
   client configuration address respond
   virtual-template 1
</pre>
<p>When a client connects using the group name <code>EWB</code>, it will check for network authorization using the AAA list name <code>sdm_vpn_group_ml_4</code> (or <code>default</code> if that list doesn&#8217;t exist), respond to IP address requests from the client (using the pool defined in the client configuration above), and create a local virtual-access interface based on virtual template number 1.</p>
<p>You should use the same group name that you used for the <strong>client configuration</strong> above, instead of EWB, unless you&#8217;re EWB of course.</p>
<h3>Strong Encryption</h3>
<p>Now we define the level of encryption used for data communications with hosts on the internal network, as opposed to securing the negotiation process. We start by defining a <em>transform set</em> which uses 256-bit AES encryption, the SHA hash algorithm and LZS compression for data packets:</p>
<pre>
crypto ipsec transform-set ewb_encryption esp-aes 256 esp-sha-hmac comp-lzs
</pre>
<p>Then we create an IPsec profile that links these settings to the ISAKMP profile that we defined above:</p>
<pre>
crypto ipsec profile ewb_ipsec_profile
 set transform-set ewb_encryption
 set isakmp-profile ewb_isakmp_profile
</pre>
<h3>Virtual Template</h3>
<p>Now we define the template for the virtual interfaces, that we referenced above in the ISAKMP policy:</p>
<pre>
interface Virtual-Template1 type tunnel
 ip unnumbered Vlan1
 zone-member security in-zone
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile ewb_ipsec_profile
</pre>
<p>We use <code>ip unnumbered Vlan1</code> to set the IP address of the virtual-access interfaces to the address of the router on the local LAN (in this case it&#8217;s a VLAN bridge), which allows you to ping the router using its internal IP address (192.168.1.1 in our case) when you&#8217;re connected to the VPN, which is a useful connectivity test.</p>
<p>We place the virtual interfaces into the <code>in-zone</code> (internal zone) which means that they have full access to the local network, which is not very secure, but simplifies things. We also specify that this interface accepts only traffic encrypted with IPsec and bound to the profile that we created earlier. I&#8217;m not sure why it needs to be bound in both directions, as the IPsec profile is connected to the ISAKMP profile which is connected to this virtual interface already.</p>
<h3>Client Setup</h3>
<p>That should be it for the server-side setup. To configure a client, install the VPN software you downloaded earlier, start it, create a new IPsec configuration, and enter the following details:</p>
<dl>
<dt>Server</dt>
<dd>The public IP address of the VPN server</dd>
<dt>Group Name</dt>
<dd>The same group name that you used on the server earlier</dd>
<dt>Pre-Shared Key</dt>
<dd>The same key that you entered on the server earlier</dd>
</dl>
<p>Now click on the <strong>Connect</strong> button, and after a few seconds the window should minimize to the system tray, and you should be connected to the VPN. You can check this by pinging the internal IP address of the router (e.g. 192.168.1.1) and if that works, the IP addresses of whatever internal servers you want to connect to.</p>
<p>If it doesn&#8217;t work, use the Log menu to enable logging, try to connect again, and check the results on the Logging tab. You can also try enabling IPsec debugging on the router, in run mode (not configuration mode):</p>
<pre>
debug crypto engine packet
debug crypto ipsec error
debug crypto isakmp error
debug crypto verbose
terminal monitor
</pre>
<p>When the configuration works, write it to the router&#8217;s non-volatile memory to ensure that you don&#8217;t lose it when you next reboot the router:</p>
<pre>
write
</pre>
<p>And that&#8217;s it!</p>
<h3>References</h3>
<p>Here are some random unsorted links to pages that I found useful while figuring out how to do this:</p>
<ul>
<li><a href="http://www.ciskoblog.com/2006/12/configuring-a-c.html">Configuring a Cisco Router to Accept VPN Connections</a> (even simpler example, without split tunnels)</li>
<li><a href="http://www.cisco.com/en/US/docs/ios/sec_secure_connectivity/configuration/guide/sec_key_exch_ipsec.html">Configuring Internet Key Exchange for IPsec VPNs</a> (good general overview of how Cisco&#8217;s IPsec works)</li>
<li><a href="http://www.cisco.com/en/US/docs/ios/sec_secure_connectivity/configuration/guide/sec_easy_vpn_rem.html#wp1060585">Cisco Easy VPN Remote</a> configuration guide</li>
<li><a href="http://samsten.net/work/cvpnc/">Cisco VPN client downloads</a></li>
<li><a href="http://www.ciscocatalyst.info/en/US/docs/ios/ipaddr/command/reference/iad_arp.html#wp1013235">Cisco ARP Commands</a></li>
<li><a href="http://www.cisco.com/en/US/products/ps6017/products_command_reference_chapter09186a00808ab59a.html#wp1016030">Cisco ISAKMP command reference</a></li>
<li><a href="http://www.cisco.com/en/US/docs/routers/access/cisco_router_and_security_device_manager/24/software/user/guide/ZPF.html#wp1020392">Configuring Zone Policy Firewalls</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/08/03/simple-cisco-vpn-how-to/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Censorship Arms Race</title>
		<link>http://blog.aptivate.org/2010/04/07/the-censorship-arms-race/</link>
		<comments>http://blog.aptivate.org/2010/04/07/the-censorship-arms-race/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 13:00:57 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[Censorship]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=423</guid>
		<description><![CDATA[No security is perfect. There will always be ways around any security measure that we implement. However, no workaround is perfect either. Once we understand how it works, e.g. what the requests that it makes look like, we can block it. This quickly turns into an arms race between the user and the administrator.]]></description>
			<content:encoded><![CDATA[<p>Preface: This post discusses censorship. I want to be clear that I represent only my own personal views here, and I don&#8217;t personally support censorship in most cases. I think that freedom of access to information has a benefit and a cost, and the tradeoff depends on circumstances.</p>
<p>I think that censorship is useful when it serves a higher purpose, for example to save lives, or to save vital money for underfunded universities in countries where bandwidth is expensive and there are alternative ways for students to access the uncensored Internet for private browsing purposes. I&#8217;m opposed to censorship that requires leaving the country or changing your ISP to get around it.</p>
<p>Walubengo wrote on the BMO Training mailing list:</p>
<blockquote><p>Am just from the student labs and came across this sneaky little [software]:</p>
<p><a href="http://www.ninjacloak.com/">http://www.ninjacloak.com/</a></p>
<p>It basically allows my students to get behind the good old<br />
dansguardian/squid proxy_firewall; essentially allowing them to visit<br />
and download all and sundry (read porn, warez, torrents et al)</p>
<p>[H]ave been wondering why the clamour to &#8220;open-up&#8221; the internet &#8220;for<br />
research&#8221; had gone down (now I know).</p>
<p>Any quick counters? (beyond just blocking ninjacloak.com, since they are likely to get an equivalent sooner rather than later)</p></blockquote>
<p>I have never used ninjacloak and I don&#8217;t intend to, but I&#8217;m sure that if you post some logs of its use from your proxy server, we can figure out how to block it.</p>
<p>However, no security is perfect. There will always be ways around any security measure that we implement. However, no workaround is perfect either. Once we understand how it works, e.g. what the requests that it makes look like, we can block it.</p>
<p>This quickly turns into an arms race between the user and the administrator. The winner is usually the one with the most time, patience and determination. This may be a fight that you don&#8217;t want to take on.</p>
<p>In my view, if users really really want to access some blocked content, they will find a way. However, a good security system will make it possible to at least trace that they did so, if not exactly what they accessed. So my approach would be two-fold:</p>
<ol>
<li>Tackle the biggest problems first, and when they make sense. If someone uses ninjacloak to view a porn site once, it is hardly going to bring down your network, so you don&#8217;t need to care. If all your students are using TOR, AND it is bringing down your network, THEN it&#8217;s time to do something about it. If you don&#8217;t know what the biggest problem is, <a href="http://www.bwmo.net/pdf/chapter3.pdf">find out</a>.</li>
<li>Don&#8217;t forget that social measures are far more effective than technical ones. If students know that they are being watched, they are much less likely to try things like this. Make REALLY sure that everyone knows and understands your <a href="http://www.bwmo.net/pdf/chapter2.pdf">policy</a>. When you find students bypassing your security, <a href="http://www.bwmo.net/pdf/chapter7.pdf">go and talk to them</a>. If necessary, consider the use of formal sanctions, which are likely to have a stronger deterrent effect.</li>
</ol>
<p>If users think they are being treated unfairly or harshly, it can increase their determination to fight the system. If you have a good reason for censoring, because you can show them how much damage their actions are causing to legitimate or intended uses (such as academic research), they are much more likely to understand and comply with your requests, hopefully avoiding the need for sanctions.</p>
<blockquote><p>nb: but again, someone may ask, why not just open up the internet any way?</p></blockquote>
<p>Because (and only when) it wastes your precious bandwidth that&#8217;s better used for your core purpose (e.g. academic research), which is why you pay for the connection in the first place.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/04/07/the-censorship-arms-race/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Network Management Basics</title>
		<link>http://blog.aptivate.org/2010/04/07/network-management-basics/</link>
		<comments>http://blog.aptivate.org/2010/04/07/network-management-basics/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 07:43:20 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Censorship]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[university]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=419</guid>
		<description><![CDATA[I&#8217;ve been asked for some advice on how schools and universities can take advantage of the increased bandwidth available with the arrival of the TEAMS and EASSY submarine cables in East Africa. Management of Internet connections is a big subject. Whole books have been written about it, including the freely downloadable How To Accelerate Your [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been asked for some advice on how schools and universities can take advantage of the increased bandwidth available with the arrival of the <a href="http://en.wikipedia.org/wiki/TEAMS_(cable_system)">TEAMS</a> and <a href="http://en.wikipedia.org/wiki/EASSy_(cable_system)">EASSY</a> submarine cables in East Africa.</p>
<p>Management of Internet connections is a big subject. Whole books have been written about it, including the freely downloadable <a href="http://bwmo.net">How To Accelerate Your Internet (BMO Book)</a>. However, for anyone who doesn&#8217;t have time to read it, I will briefly summarise the most important points that I can think of:</p>
<ul>
<li>have a clear, simple and strict <a href="http://bwmo.net/pdf/chapter2.pdf">Internet access policy</a>, and enforce<br />
it.</li>
<li>have enough bandwidth, AT LEAST 3 kbps per computer, uncontended. So if you have 1000 computers, you should have 3 MBits dedicated bandwidth, or 60 MBps if it&#8217;s shared or contended with a 20:1 contention ratio (typical ISPs).</li>
<li>have competent network administrators. If you don&#8217;t have them, then hire or train them.</li>
<li>implement good network management practices, e.g. by following the advice of the <a href="http://bwmo.net/">BMO Book</a>.</li>
<li>start by <a href="http://bwmo.net/pdf/chapter5.pdf">solving</a> the problems that users complain most about, to give them the best possible service.</li>
<li><a href="http://bwmo.net/pdf/chapter3.pdf">monitor your network</a> to understand how Internet bandwidth is being used.</li>
<li><a href="http://bwmo.net/pdf/chapter4.pdf">block misuses</a> of Internet access that are causing problems for legitimate use of the Internet connection.</li>
<li>ensure that client PCs have good, fast antivirus, perform well, are<br />
regularly reformatted and reimaged, and have strong local security to prevent unauthorized software installation.</li>
</ul>
<p>Far more information on all of these topics can be found in the BMO book. I suggest starting with the <a href="http://bwmo.net/pdf/chapter1.pdf">Introduction</a> if you&#8217;re interested.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/04/07/network-management-basics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSH Port Forwarding</title>
		<link>http://blog.aptivate.org/2010/03/10/ssh-port-forwarding/</link>
		<comments>http://blog.aptivate.org/2010/03/10/ssh-port-forwarding/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:22:47 +0000</pubDate>
		<dc:creator>Chris Wilson</dc:creator>
				<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[forwarding]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[socks]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://blog.aptivate.org/?p=240</guid>
		<description><![CDATA[SSH port forwarding is not hard to do, once you get your head around how it actually works. It's not like a VPN and it's not magic. It's quite like a proxy server.]]></description>
			<content:encoded><![CDATA[<p>David Sumbler <a href="http://mailman.linuxchix.org/pipermail/techtalk/2010-January/023958.html">wrote</a> to the LinuxChix mailing list:</p>
<blockquote><p>She now has two computers connected via an ADSL router.  Both computers run Ubuntu (8.06 and 9.10).  I have set things up so that I can log into the router, and also SSH to both computers simultaneously: I use two different port numbers&#8230;</p>
<p>I now want to be able to see her desktops, but I haven&#8217;t figured out how to do this. Having read the Gnome help, I believe that the Gnome remote desktop is inherently insecure: I would prefer to tunnel things over SSH, probably using vncserver and vncviewer (or perhaps Vinagre).</p>
<p>Can anybody explain what I need to do to get this to work, please?</p></blockquote>
<p>I get asked this kind of question so often that I thought I&#8217;d write it up somewhere so I could just point people to the post.</p>
<p>SSH port forwarding is not hard to do, once you get your head around how it actually works. Thanks to Alan for drawing this simple diagram:</p>
<p><a href="http://blog.aptivate.org/wp-content/uploads/2010/03/ssh-port-forwarding-diagram.jpg"><img src="http://blog.aptivate.org/wp-content/uploads/2010/03/ssh-port-forwarding-diagram.jpg" alt="" title="SSH Port Forwarding Diagram" width="548" height="277" class="alignnone size-full wp-image-410" /></a></p>
<p>SSH port forwarding is not like a VPN and it&#8217;s not magic. It&#8217;s quite like a proxy server:</p>
<ul>
<li>You tell SSH, with the <code>-L</code> option, to listen for connections on a port on your local side.</li>
<li>SSH connects to the remote host immediately as usual, and then starts listening on this port.</li>
<li>When it receives a connection on this port, it tells the other side (the SSH server that you connected to) to connect to the remote hostname and port that you specified.</li>
<li>If the remote side succeeds, the two SSH processes join the two sides together, forwarding bytes from each side to the other.</li>
</ul>
<p>(Note: it&#8217;s also possible to ask the remote SSH server to listen on a port on its side, with the <code>-R</code> option, and connect to a host and port on the client side, but in the interests of simplicity I will ignore that for today.)</p>
<p>I&#8217;ll show you the commands that I <a href="http://mailman.linuxchix.org/pipermail/techtalk/2010-January/023960.html">suggested</a> to David, and then explain what they do:</p>
<pre>ssh <strong>username</strong>@<strong>ip-address-of-ssh-server</strong> -p <strong>port1</strong> -L 5901:localhost:5900
ssh <strong>username</strong>@<strong>ip-address-of-ssh-server</strong> -p <strong>port2</strong> -L 5902:localhost:5900
vncviewer localhost:1 (connects to computer 1)
vncviewer localhost:2 (connects to computer 2)</pre>
<p>This opens two SSH connections, one to each of the machines behind his firewall, which are completely independent of each other. One SSH connection would actually be enough, as we will see in a minute, but this way fit more logically with my explanation.</p>
<p>These commands contain some placeholders that must be adapted to your situation:</p>
<dl>
<dt><strong>username</strong></dt>
<dd>The user name that you want to connect as. You can omit the name and the @ sign if it&#8217;s the same as your logged-in user on the client.</dd>
<dt><strong>ip-address-of-ssh-server</strong></dt>
<dd>The IP address or hostname of the SSH server that you want to connect to. In David&#8217;s case, he can&#8217;t see the SSH server directly, so he needs to use the public IP address of the router here, and the router will forward the port to the SSH server on his internal network.</dd>
<dt><strong>port1</strong> and <strong>port2</strong></dt>
<dd>David said that he can &#8220;SSH to both computers simultaneously [using] two different port numbers.&#8221; Presumably using port forwarding on his router. These are the two port numbers.</dd>
<dt><strong>vncviewer localhost:1</strong></dt>
<dd>This runs the VNC viewer on the client and tells it to connect to VNC display 1, which runs on port 5901 (by definition, VNC ports are display number plus 5900), which we already forwarded to computer 1 using SSH.</dd>
</dl>
<p>After running the two <code>ssh</code> commands command, the first SSH client will be listening on port 5901 on the machine that you run it on, and the second will be listening on port 5902.</p>
<p>After this, until you disconnect the SSH sessions or kill the clients in some way, whenever you connect to port 5901 on the client, it will tell the computer it&#8217;s connected to (computer 1) to connect to localhost port 5900 (that is, to its own VNC server) and then join the connections together, forwarding any data sent in either direction over the tunnel.</p>
<p>This part of the SSH command:</p>
<pre>-L 5902:localhost:5900</pre>
<p>tells the SSH client to <strong>L</strong>isten on port 5902 on the client, and when it receives a connection, to ask the other side (the server) to connect to (what it sees as) localhost port 5900, and SSH will forward communications between the two over the SSH tunnel.</p>
<p>Note first of all that we tell <code>vncviewer</code> to connect to <code>localhost</code>, not to the IP of the remote computer (internal or external). That&#8217;s because the client side of the SSH port forwarding is listening on <code>localhost</code> port 5901, and not any other IP address or port. If you connect to anything other than <code>localhost</code> port 5901, you will not end up talking to the local SSH client connected to <em>computer 1</em>.</p>
<p>Note secondly that when we created the tunnels, we told the ssh client to connect them to port 5900, also on localhost. This time, localhost is relative to the <strong>remote</strong> machine (the server), so we are telling it to connect to itself (<strong>not</strong> back to you). We could also specify any IP address and port that is reachable to the server, which is acting as our proxy in this case. However, we cannot specify an IP or port that is reachable to the client but not to the server, because the server will not be able to connect to it.</p>
<p>Now let&#8217;s imagine that we want to be able to VNC to both computers over a single SSH tunnel. We can do this by forwarding two different local ports, one to localhost, and one to the IP address of the other computer, like this:</p>
<pre>ssh <strong>username</strong>@<strong>ip-address-of-ssh-server</strong> -p <em>port1</em> -L 5901:localhost:5900 -L 5902:192.168.10.5:5900
vncviewer localhost:1 (connects to computer 1)
vncviewer localhost:2 (connects to computer 2)</pre>
<p>This assumes that computer 2 has the internal (RFC1918) IP address 192.168.10.5, and allows connections from computer 1 to its port 5900.</p>
<p>Port forwarding is unlike a VPN in several ways. The client does not end up with routing to the ultimate destination, nor does it need it. This means that it works even if the client and server have different views of the IP space, for example if they are located in subnets that use the same IP range to refer to different machines.</p>
<p>The server does not try to connect to the ultimate destination until the client receives an incoming connection (e.g. from <code>vncviewer</code> in this case). At this point, it may discover that there is nothing listening on the port to which it was told to connect, or that the destination host is down, or the port is blocked by a firewall. The server informs the client of this, but the client has no way to pass this information onto the connection that it received, which is has already accepted. All it can do is close the connection.</p>
<p>This means, for example, that if you were to sit at the server and type <code>vncviewer 192.168.10.5</code>, and that computer was not running VNC, you might get a <code>Connection refused</code> error. However, if you sit at the client and type <code>vncviewer localhost</code>, you will see the connection is opened and immediately closed, as though the VNC process was listening but refused to talk to you for some reason. Do not be fooled into assuming that VNC is running on the destination. With SSH port forwarding, you have no idea.</p>
<p>You cannot forward ICMP (pings), UDP sockets (DNS) or any other protocol except TCP using port forwarding, so you will never be able to ping remote hosts using this method alone.</p>
<p>It is currently impossible to add new forwarded ports to an existing connection or to change the ultimate destination host and port, so you must disconnect and reconnect with a new command line instead. This is inconvenient in some cases, especially where you have a long-running process open in the shell. I recommend using <code>ssh -N</code> to open an ssh client that does only port forwarding and not a shell; then open a separate shell if you need one.</p>
<p>The ssh client cannot exit while any connection is open, so if you log out with connections open, it will appear to hang. All open connections will be closed if the ssh client is forcibly killed by a signal or escape character.</p>
<p>If your port forwarding doesn&#8217;t appear to be working, check that you don&#8217;t have another process listening on the same port. For example, in the VNC case, both Gnome and KDE desktop sharing create a VNC server on the standard port, 5900, so you cannot forward the local port 5900 to anywhere if you have remote desktop access enabled on the client. The easiest solution is to listen on different port numbers, like 5901 and 5902, which correspond to VNC displays 1 and 2 in the command examples above.</p>
<p>Finally, please note that the meaning of commands like these is very different depending on where it is run (on the client or on the server):</p>
<pre>vncviewer localhost
vncviewer 192.168.10.5</pre>
<p>This is because:</p>
<ul>
<li>The meaning of <code>localhost</code> is different depending on where you run it (on the client or on the server); it always means connecting to the same computer that the command is running on.</li>
<li>The meaning of <code>192.168.10.5</code> (or any other IP address) similarly depends on where you run it (on the client or on the server); it is always relative to the computers that are reachable from the one running the command.</li>
<li>Connections always appear to the recipient to be coming from the computer running the command, so when the client or the server connects to 192.168.10.5, even if that&#8217;s the same computer for both, it will see the connections coming from different IP addresses.</li>
</ul>
<p>Tariq adds that you can also run:</p>
<pre>
ssh -D 9999 <strong>username</strong>@<strong>ip-address-of-ssh-server</strong>
</pre>
<p>where the <code>-D</code> option tells SSH to creates a <a href="http://en.wikipedia.org/wiki/SOCKS_(Protocol)">SOCKS</a> proxy server tunnel. You can then tell your web browser (and other clients with SOCKS support) to use localhost:9999 as a SOCKS proxy server. This will forward all your browsing through the SSH tunnel, which makes it look like you&#8217;re in a different location (e.g. to watch iplayer when not in the UK) and protects your unencrypted web browsing from random sniffers on public networks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.aptivate.org/2010/03/10/ssh-port-forwarding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

