<?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>Robert Penz Blog &#187; IT Security</title>
	<atom:link href="http://robert.penz.name/category/it-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://robert.penz.name</link>
	<description>About Linux, IT security,tips and tricks and otherstuff that comes into my mind</description>
	<lastBuildDate>Fri, 20 Jan 2012 15:34:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Howto connect multiple networks over the Internet the cheap way</title>
		<link>http://robert.penz.name/312/howto-connect-multiple-networks-over-the-internet-the-cheap-way/</link>
		<comments>http://robert.penz.name/312/howto-connect-multiple-networks-over-the-internet-the-cheap-way/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 18:56:57 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=312</guid>
		<description><![CDATA[I&#8217;m quit often asked by 2 types of people how to connect cheaply multiple networks securely over the Internet. The first type are owners of small companies which have more than one office and want to connect them to their central office. And the other type are people who are the de facto IT guy [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m quit often asked by 2 types of people how to connect cheaply multiple networks securely over the Internet. The first type are owners of small companies which have more than one office and want to connect them to their central office. And the other type are people who are the de facto IT guy for their family and friends and need an easy way to get into the the other networks.</p>
<p>In the beginning most of them start with with remote connection software like Teamview, VNC, but at some point thats not enough anymore, when the responsibilities grow. The solution that I implement for them is based on the <a href="http://openvpn.net/" target="_blank">OpenVPN</a> which is a well know, free and secure Open Source VPN solution, which is able to run on cheap hardware. Why do I say it needs hardware when you see on their homepage that it runs on Windows too?</p>
<ol>
<li>You want a system with which nobody messes around and so it works for years without ever touching it again. And yes that is possible with the proposed solution. If you can&#8217;t reach the router it normally a ISP problem or power outage.</li>
<li>You don&#8217;t have only one Computer in each network and one VPN for each computer is not a good idea if you don&#8217;t need it.</li>
<li>There are also devices in the network where you can&#8217;t or won&#8217;t install a VPN software. e.g. printer, TV, receiver, acess point, &#8230;.</li>
</ol>
<p>Anyway you can also use this setup to let road warriors into your network over the Internet. I&#8217;ll also show how to do that, but it is not the main focus of this blog post.</p>
<p>So about what hardware I&#8217;m talking?</p>
<ol>
<li>An Accesspoint/DSL/Cable Router which is able to run OpenWRT, or any other system for which OpenVPN is available. I basically stick with systems that can run OpenWRT as I want similar systems to minimize my efforts. To be precise I&#8217;m almost always use a Linksys WRT54GL which you get under 40 Euros. But you&#8217;re free to use anything else. e.g. a friend of mine has a setup working with a <a title="SheevaPlug" href="http://en.wikipedia.org/wiki/SheevaPlug" target="_blank">SheevaPlug</a> and Debian on it, an other has a setup running with <a href="http://www.dd-wrt.com/" target="_blank">DD-WRT</a>.</li>
<li>If you have a local server in the network, be it Linux or Windows based, you can use that do. But don&#8217;t use clients if its not for road warriors.</li>
</ol>
<p><strong>The Setup</strong></p>
<p>You need one OpenVPN node per network/location. In the following example we have</p>
<ul>
<li>one central office network with a server and the router is from Internet service provider and we cannot install software on it, the server is also used as DHCP server. (I&#8217;ve specially selected that as it shows what additionally needs to be done if the OpenVPN server is not the default gateway for the devices in the network. If for your setup thats in a remote location its the same setup there.)</li>
<li>one remote office which is connected via cable the Internet. An OpenWRT based router is connected to the cable modem and <a href="http://en.wikipedia.org/wiki/IP_masquerading" target="_blank">masquerades</a> the devices behind it.</li>
<li>one remote office which is connected via DSL to the Internet. An OpenWRT based router inserted after the provider router, both masquerades and to make the life interesting you cannot change anything on the provider router, e.g. add a port forwarding</li>
</ul>
<p>In this howto we&#8217;re working with following subnets:</p>
<ul>
<li>10.23.0.0/24 &#8211; central office</li>
<li>10.23.1.0/24 &#8211; remote office 1</li>
<li>10.23.2.0/24 &#8211; remote office 2</li>
<li>10.23.255.0/24 &#8211; transport network remote offices</li>
<li>10.23.254.0/24 &#8211; transport network road warriors (not in the figure)</li>
</ul>
<p style="text-align: center;"><img class="size-full wp-image-317  aligncenter" title="network diagram" src="http://robert.penz.name/wp-content/uploads/2010/10/openvpn_network_blogpost-01.png" alt="network diagram" width="500" height="998" /></p>
<p>In the figure above you see that each Network has a different subnet &#8211; this is important as we need to route packets! <strong>Advise: </strong>Always use different subnets for different locations you set up. Even if you don&#8217;t connect them together at the beginning, make a list which subnets you&#8217;ve already used. There are plenty subnets in the <code>10.0.0.0 - 10.255.255.255</code> range for a single guy or a small company. Use a separate C class networks for each location (e.g. <code>10.42.0.0/24</code> for the first, <code>10.42.1.0/24</code> for the second and so on).</p>
<p>One subnet is needed as transit network within the VPN to connect the all remote offices to the central one. One subnet is only needed if you also want road warriors to connect to your network.</p>
<p><strong>Preconditions</strong></p>
<p>Common to all locations:</p>
<p>Get OpenVPN installed on all 3 systems. The version can differ a little between the servers which makes it easy if your OpenWRT router has an older version as you use for your main server.</p>
<p>Central office:</p>
<ul>
<li>You need to forward 2 UDP ports on the ISP router from the Internet to your server. The example ports I use in this howto are <code>10000</code> for the VPN connection of the remote offices and <code>10001</code> for the road warriors.</li>
<li>Create an DNS entry for the external IP address of your router. If you&#8217;ve a dynamic IP address or no own DNS server/domain you can use for example the <a href="http://www.dyndns.com/" target="_blank">dyndns.com service</a>; during this howto I assume centraloffice.dyndns.org as the host name.</li>
<li>You need to add a routing rule in your DHCP config which tells the clients that <code>10.23.0.0/16</code> is reachable behind the IP of your sever. And yes the <code>10.23.0.0/16</code> also includes the <code>10.23.0.0/24</code> of the central office, but it is important to remember that the more specific rule counts. The usage of one <code>10.23.0.0/16</code> and not a rule for ech C Class subnet allows you to add remote offices later without changing the DHCP. If your DHCP server is not able to add routing rules,  a workaround is possible if your default gateway used by the clients (in this case the ISP router) is able to add the <code>10.23.0.0/16</code> rule to its routing table. In this case every traffic goes first to the default gateway and then back to the server. Thats not nice but for a small network with only a low bandwidth connection to the other networks it is ok. In a big network the security / network guy will cry&#8230;..</li>
<li>Make sure that routing is enable on the server. On Linux systems you can check that easily with <code>cat /proc/sys/net/ipv4/ip_forward</code>. If the result is 1 it is enabled otherwise not.</li>
<li>Make sure that if you&#8217;ve a local firewall enabled that UDP ports <code>10000</code> and <code>10001</code> are open.</li>
</ul>
<p>Remote offices:</p>
<p>All requirements are meet if you&#8217;ve installed a modern version of OpenVPN and if the systems have the correct time. This maybe harder than it sounds as most DSL routers don&#8217;t have an internal clock that survives reboot. But it is important that the time of the router is bigger than the time the certificates where created, as otherwise the systems will not accept the certificate of the node in the central office. An easy way to make sure that at least this requirement is fulfilled is to set the date at boot to something fixed. I&#8217;ll show a simple way to do this later.</p>
<p><strong>Firewall considerations</strong></p>
<p>OpenVPN uses <code>tun*</code> device names for the VPN tunnels. On the central  office server you&#8217;ve have <code>tun0</code> for the remote offices and <code>tun1</code> for the  road warrios. For testing purposes you should let any traffice from and  to <code>tun0,tun1</code> and <code>eth0</code> (LAN interface) through. After you made sure that  everything works you should limit that to traffic which is really  needed. On the remote offices nodes I recommend to open the traffic  permanently in both directions (<code>eth0</code> to <code>tun0</code> and <code>tun0</code> to <code>eth0</code>) as  otherwise you need to administer the firewall rules on on multiple  systems.</p>
<p><strong>Import: </strong>You need also firewalls rules (on the central office server) that allow the traffic from one  remote office to the other if you wish that kind of traffic. OpenVPN will be  configured in a way that lets that kind of traffic through but without  firewall rules that also allow the traffic it will not work.</p>
<p><strong>Setting up a Certicate Authority (CA)</strong></p>
<p>So what is  a CA? I copied the first paragraph and linked the<a href="http://en.wikipedia.org/wiki/Certificate_authority" target="_blank"> explanation of wikipedia</a> as a starting point.</p>
<p><em>In cryptography, a certificate authority or certification authority (CA) is an entity that issues digital certificates. The digital certificate certifies the ownership of a public key by the named subject of the certificate. This allows others (relying parties) to rely upon signatures or assertions made by the private key that corresponds to the public key that is certified. In this model of trust relationships, a CA is a trusted third party  that is trusted by both the subject (owner) of the certificate and the party relying upon the certificate. CAs are characteristic of many public key infrastructure (PKI) schemes.</em></p>
<p>In more common words each VPN nodes needs to have a one certificate (*.crt &#8211; containing the public key and the signature of the CA) and one private key. Each node needs to trust the CA and for this they have the certificate of the CA stored. For each node you need therefore at least 3 cryptography files. The certificate file also contains a flag describing a node as server or client. We&#8217;ll configure the OpenVPN clients in a way that will make sure that they connect only to nodes with the server flag.</p>
<p>The CA should be not on one of the VPN nodes but on separate computer. The easiest way to reach a working and secure enough solution for a small company is to put the CA onto a USB stick and only insert it on a secure PC if you&#8217;ll need it for generating new certificates.</p>
<p>Now lets get to the doing part, I&#8217;ll will assume that you&#8217;ve a Linux or Linux like system as your CA system but it will also work on others. In your OpenVPN package you&#8217;ll find a directory or .gz file named something like easy-rsa-2.0. On an Ubuntu/Debian system you&#8217;ll find it under <code>/usr/share/doc/openvpn/examples/easy-rsa/2.0/</code> after installing the package openvpn.</p>
<ol>
<li>Copy or extract easy-rsa to a directory of your liking.</li>
<li>Open the <code>vars</code> file in a text editor and scroll down to the end of the file. There you can change the key length to something higher than 1024 but keep in mind that you&#8217;ve not the fastest systems if you&#8217;re using OpenWRT on a DSL Router. You should also change the default country, city, &#8230; entries. The default lifetime of the certificates with 10 years should be enouch <img src='http://robert.penz.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
<li>Type <code>. vars</code> which will load the variable in the environment of your current shell. You need to this step every time you start with an fresh shell and want todo any CA operation.</li>
<li>Call <code>./clean-all</code> &#8211; <strong>Important:</strong> Only do that in the beginning as it will delete your complete CA and certificates if you&#8217;ll use it later.</li>
<li>Call <code>./build-ca mycompany-ca</code> to generate the CA, you can leave most questions to the default answers. The important part the common name is already specified a command line parameter.</li>
<li>Call <code>./build-dh</code> to get a special file for the OpenVPN node in the central office</li>
<li>Call <code>./build-key-server centralofficenode</code> to generate the certificate for your central office node. Change the name to something meaningfull.<strong> Important:</strong> The name (= common name) needs to be unique for all nodes and I recommend to use only <code>A-Z,a-z,0-9,-,_</code> as common name.</li>
<li>Call <code>./build-key remoteofficenode</code> for each remote location you want to connect. <strong>Important:</strong> Use a system to choose the names otherwise you&#8217;ll loose overview of it if you&#8217;ll get more nodes and subnets. e.g. the name of the location/network you typically use to refer to it.</li>
</ol>
<p>You&#8217;ll find all files in the keys subdirectory and you need to copy the .crt, .key of each node and the CA file to the node (and not the files for an other node!) For the node in the central office you need also the dh1024.pem.</p>
<p>road warriors:</p>
<p>If you also want to setup a VPN service for road warriors I recommend to use a separate CA &#8211; so make a second copy of the easy-rsa and start again. Import use other names otherwise you will loose the overview.</p>
<p><strong>OpenVPN configuration</strong></p>
<p>Central office:</p>
<p>I assume in this howto that it is a Linux server (Ubuntu/Debian based to be exact) in your central office, but the configuration on for example Windows is the basically the same &#8211; just the paths, starting methods and logging stuff are different.</p>
<ol>
<li>Create the directory <code>/etc/openvpn/certs/</code> and copy the <code>centraloffice.crt</code>, <code>centraloffice.key</code>, <code>ca.crt</code> and the <code>dh1024.pem</code> to this directory and change the permissions for the directory to <code>700</code> and for all files to <code>600</code> and the owner should be root for both.</li>
<li>Create a config file <code>/etc/openvpn/0_remote_offices.conf</code> with following content:<br />
<code><br />
port 10000<br />
proto udp<br />
dev tun<br />
ca /etc/openvpn/certs/ca.crt<br />
cert /etc/openvpn/certs/centraloffice.crt<br />
key /etc/openvpn/certs/centraloffice.key<br />
dh /etc/openvpn/certs/dh1024.pem<br />
server 10.23.255.0 255.255.255.0<br />
client-to-client<br />
client-config-dir /etc/openvpn/remoteoffice_networks<br />
verb 3<br />
# we can here operate with the same B class network as the more specify rules counts<br />
route 10.32.0.0 255.255.0.0<br />
push "route 10.32.0.0 255.255.0.0"<br />
keepalive 10 120<br />
cipher AES-128-CBC   # AES<br />
comp-lzo<br />
max-clients 100<br />
persist-key<br />
persist-tun<br />
</code></li>
<li>Create the directory <code>/etc/openvpn/remoteoffice_networks</code> and insert one file for each remote relocation with the name of the common name you choose for it. The files contain only one line with following content for the first remote location <code>iroute 10.23.1.0 255.255.255.0</code> and <code>iroute 10.23.2.0 255.255.255.0</code> for the second remote location. This tells OpenVPN which remote network is reachable behind which node.</li>
<li>Optional: Copy the road warrior CA stuff needed to the certs directory. <strong>Important:</strong> Make sure that you use an other name as ca.crt, as you&#8217;ve that one for the remote offices.<br />
5. Optional: Create a configuration file <code>/etc/openvpn/1_remote_offices.conf</code> with following content for the road warriors:<br />
<code><br />
port 10001<br />
proto udp<br />
dev tun<br />
ca </code><code>/etc/openvpn/</code><code>certs/ca_roadwarrior.crt<br />
cert </code><code>/etc/openvpn/</code><code>certs/centraloffice_roadwarrior.crt<br />
key </code><code>/etc/openvpn/</code><code>certs/centraloffice_roadwarrior.key<br />
dh </code><code>/etc/openvpn/</code><code>certs/centraloffice_dh1024.pem<br />
server 10.23.254.0 255.255.255.0<br />
verb 3<br />
push "route 10.23.0.0 255.255.0.0"<br />
keepalive 10 120<br />
# Maybe you need to comment this out, as your e.g. Windows client uses an slightly other encoding and so you can't transfer data. But if possible AES is the best.<br />
cipher AES-128-CBC   # AES<br />
comp-lzo<br />
max-clients 100<br />
persist-key<br />
persist-tun<br />
</code></li>
<li>Restart the OpenVPN server with <code>/etc/init.d/openvpn restart</code> and check if the configuration was at least that much correct to start up.</li>
<li>Run <code>tail -f /var/log/syslog</code> (or your distribution equivalent) to check on entries if the OpenVPN clients try to connect.</li>
</ol>
<p>Remote Offices:</p>
<p>You need to do following steps for each remote office and replace the filenames with the correct ones for the specify remote location.</p>
<ol>
<li>Create the directory <code>/etc/openvpn/certs/</code> and copy the <code>remoteoffice*.crt</code>, <code>remoteoffice*.key</code> and <code>ca.crt</code> to this directory and change the permissions for the directory to <code>700</code> and for all files to <code>600</code> and the owner should be root for both.</li>
<li>Create a config file <code>/etc/openvpn/0_to_the_central_office.conf</code> with following content:<br />
<code><br />
client<br />
dev tun<br />
proto udp<br />
remote centraloffice.dyndns.org 10000<br />
resolv-retry infinite<br />
ns-cert-type server<br />
cipher AES-128-CBC<br />
ping 15<br />
ping-restart 45<br />
ping-timer-rem<br />
persist-tun<br />
persist-key<br />
comp-lzo<br />
verb 3<br />
ca /etc/openvpn/certs/ca.crt<br />
cert /etc/openvpn/certs/remoteoffice*.crt<br />
key /etc/openvpn/certs/remoteoffice*.key<br />
</code></li>
<li>Create an init.d script <code>/etc/init.d/openvpn</code> with the permissions <code>755</code> and the content:<br />
<code><br />
# change the date to something bigger than the time you used to generate the certificates<br />
date -s "2010-03-01 10:00:00"<br />
cd /etc/openvpn<br />
openvpn --config /etc/openvpn/0_to_the_central_office.conf --daemon<br />
</code></li>
<li>Create an symlink to start the init.d script automatically.<br />
<code><br />
cd /etc/rc.d/<br />
ln -s ../init.d/openvpn S65openvpn<br />
</code></li>
<li>For the first test you should do the steps in the init.d script by hand to check if they work and to see potential errors. For this don&#8217;t copy the <code>--daemon</code> parameter for the OpenVPN as this way you&#8217;ve see all errors and can easily stop OpenVPN with <code>CRTL-C</code>. Look also at the OpenVPN log entries on the central office node as it may also contain important error message.</li>
</ol>
<p>Road Warriors:</p>
<p>The configuration file looks similar to the remote offices ones, just use the <code>10001</code> port and use the files from the road warrior CA. On Windows you should use the GUI version of OpenVPN which needs the configuration file normally in <code>c:\programs\openvpn\conf</code> with the extension <code>.ovpn</code>. Copy also the files into the same directory and use no absolute paths as it may varies on different clients and you don&#8217;t want to change it for every client.</p>
<p><strong>Conclusion</strong></p>
<p>I hope this howto has shown how easily you can connect various networks via the Internet with Open Source tools and cheap hardware. I&#8217;ve you&#8217;ve any questions please write them in the comments below that post, I&#8217;ll try to answer them. This setup is only the beginning, if there is interest I can show some stuff I use to extend this setup. I&#8217;ve also written a <a href="http://robert.penz.name/21/ovpncncheck-an-openvpn-tls-verify-script/" target="_blank">blog post</a> some time ago which is interesting for you if you use the same CA for different VPN Server and want to make sure that only a some clients are allowed to connect to a specific server.</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/312/howto-connect-multiple-networks-over-the-internet-the-cheap-way/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Free SSL certificates will be supported in IE/Windows [Update]</title>
		<link>http://robert.penz.name/212/free-ssl-certificates-will-be-supported-in-iewindows/</link>
		<comments>http://robert.penz.name/212/free-ssl-certificates-will-be-supported-in-iewindows/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 14:42:12 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[IT Security]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=212</guid>
		<description><![CDATA[In the StartCom Blog the head of the company writes that its CA will be included by Microsoft. He states, &#8220;Starting approximately the 22nd of September, Microsoft intends to distribute a non-security update package to the Windows operating systems which includes the trusted StartCom root certificate and the automatic root certificate update service will update [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://blog.startcom.org/?p=205">StartCom Blog</a> the head of the company writes that its CA will be included by Microsoft. He states, <em>&#8220;Starting approximately the 22nd of September, Microsoft intends to distribute a non-security update package to the Windows operating systems which includes the trusted StartCom root certificate and the automatic root certificate update service will update the cryptographic certificates root store on those systems whenever a StartCom issued certificate is encountered.&#8221;</em></p>
<p>Why is this worth reporting? This CA is with the above mentioned date the first CA which provides a Free SSL certificate which is supported by Microsoft and therefore by all Internet Explorer browsers. Sure this is &#8220;only&#8221; a SSL certificate which only assures the domain name or email address, but this is much more than now. You find many small mail servers where the webmail/IMAP/POP3/SMTP or a small homepage for a few users is self signed. All these can now be protected much better, the only problem seems to be that the CA is not supported by Firefox and other open source players. The other authority I know which provides free SSL certificates is <a href="http://www.cacert.org">CAcert</a>. They are much stronger in the open source world, but with the inclusion of the StartSSL CA by Microsoft, they will have a much lower install base of browsers than <a href="http://www.startssl.com/">StartSSL</a>.</p>
<p><strong>[Update]</strong> Mozilla and Apple support this CA for years already. My error &#8211; sorry. So these Free SSL certs are really something for a small website or mail server.<strong>[/Update]</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/212/free-ssl-certificates-will-be-supported-in-iewindows/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Search for reduced SPAM load – Part 2</title>
		<link>http://robert.penz.name/176/the-search-for-reduced-spam-load-%e2%80%93-part-2/</link>
		<comments>http://robert.penz.name/176/the-search-for-reduced-spam-load-%e2%80%93-part-2/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 17:05:39 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=176</guid>
		<description><![CDATA[As my first ideas discussed in the first part of this series didn&#8217;t work out as I liked it, I went ahead and looked for other means to withstand these waves. If packets and connections should not reach courier, I would need to use a smtp proxy or to something with the Linux kernel. As [...]]]></description>
			<content:encoded><![CDATA[<p>As my first ideas discussed in the <a href="http://robert.penz.name/173/the-search-for-reduced-spam-load-part-1/">first part</a> of this series didn&#8217;t work out as I liked it, I went ahead and looked for other means to withstand these waves. If packets and connections should not reach courier, I would need to use a smtp proxy or to something with the Linux kernel. As the <a href="http://www.openbsd.org/spamd/">OpenBSD spamd</a> is not available for Linux,  I looked than through the iptables documentation and found the <a href="http://www.snowman.net/projects/ipt_recent/">ipt_recent</a> module.</p>
<p>It provides a userspace interface which enables a script/program to add IP addresses to a list which get them drop/reject for a given time. I thought this is exactly what I need. Why?</p>
<p>I cannot just drop/reject packages of IPs which are in DNS RBL, as maybe there is a false positive and he needs to know that there is a problem. The mail server needs therefore to send a 5xx the first time, but it is quite ok I think to not except connections for him some minutes after this.</p>
<p>This setup should at least give courier time to close the connections within the timeout, and denies a spammer trying to deliver more than one mail, or keep the connection up by ignoring the 5xx. So I went ahead. First I loaded the iptables module with an option to allow more IP addresses stored.</p>
<p><code><br />
modprobe ipt_recent ip_list_tot=1000<br />
</code></p>
<p>I think 1000 is quite on the low end, as the spam waves easily reach them. Than I added following iptables commands to my firewall script.</p>
<p><code><br />
# build sub chain<br />
$iptables -N SPAMMER<br />
# move all incomming smtp traffic there<br />
$iptables -A INPUT -p tcp --dport 25 -j SPAMMER<br />
# check if the source ip is already in the list, if so give it another 60 sec and drop the packages<br />
$iptables -A SPAMMER -m recent --name spammer --update --seconds 600 -j DROP<br />
</code></p>
<p>As you can see we drop the packets for 10 minutes. If a packet is send within that 10min the time period starts again.</p>
<p>You can test your setup by doing following.</p>
<p><code><br />
echo +1.1.1.1 &gt;/proc/net/ipt_recent/spammer<br />
</code></p>
<p>and take a look at</p>
<p><code><br />
cat /proc/net/ipt_recent/spammer<br />
</code></p>
<p>Replace 1.1.1.1 by an IP address of a spammer (just look in your logfile <img src='http://robert.penz.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) and see it working. Ok, now that we have the kernel/iptables part we need a script which adds the IP addresses of spammers on a DNS RBL after the first 5xx to the ipt_recent list.</p>
<p>As this is only for testing at this point I wrote a small script which watches the mail.log file and looks for 511 errors (the courier error code for DNS RBL hits) and add the IP addresses of the sending servers/zombies to ipt_recent.</p>
<p>Here is the python script: <a href="http://robert.penz.name/wp-content/uploads/2009/07/watchForSpammers.py">watchForSpammers.py</a>. I don&#8217;t go into any details it is quite easy anyway. Start it like this within screen (<code>apt-get install screen</code>) to keep it alive even after logout.</p>
<p><code><br />
./watchForSpammers.py /var/log/mail.log<br />
</code></p>
<p>The script does its work and adds IP addresses to the ipt_recent list which blocks them also nicely. Just type following to verify it.</p>
<p><code><br />
iptables -L -xvn<br />
</code></p>
<p>You will see a line like this.</p>
<p><code><br />
Chain SPAMMER (1 references)<br />
pkts      bytes target     prot opt in     out     source               destination<br />
15213   724935 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           recent: UPDATE seconds: 600 name: spammer side: source<br />
</code></p>
<p>But the big question is, does it help against the spam waves and its length and heights? More No than Yes <img src='http://robert.penz.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> . It does almost nothing against the height, but it allows courier to go back a little faster to normal. But still my mail server is maxed out.</p>
<p>So I continue to search for another way. Any ideas?</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/176/the-search-for-reduced-spam-load-%e2%80%93-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Search for reduced SPAM load &#8211; Part 1</title>
		<link>http://robert.penz.name/173/the-search-for-reduced-spam-load-part-1/</link>
		<comments>http://robert.penz.name/173/the-search-for-reduced-spam-load-part-1/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 17:50:31 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=173</guid>
		<description><![CDATA[This is the first part of a series of articles which show the various ways I try to reduce the memory and CPU usage on one of my mail server due spammer. Why a series? The first and obvious ideas didn&#8217;t work &#8230;&#8230; but lets start from the beginning. One of the mail server I [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first part of a series of articles which show the various ways I try to reduce the memory and CPU usage on one of my mail server due spammer. Why a series? The first and obvious ideas didn&#8217;t work &#8230;&#8230; but lets start from the beginning.</p>
<p>One of the mail server I manage is for a small software company which sells products mainly to Windows power users. As the email addresses are in every product/readme and on the homepage the server get a lot of spam. I use courier as MTA and IMAP backend for it. To fight the spam I&#8217;m using DNS RBL as first line of defense, followed by greylisting, spam assassin and some other stuff.</p>
<p>The ratio of spam which gets through is quite low but thats not the problem at this point. The problem are the spam waves that hit the server several times a day. Normally the system has under 30 open SMTP connections to/from others server, but within minutes that value raises drastically. For example look these values which show the amount of open SMTP connections at the given moment.</p>
<p><code><br />
Mon Jul 27 19:12:17 CEST 2009     4<br />
Mon Jul 27 19:12:22 CEST 2009     5<br />
Mon Jul 27 19:12:27 CEST 2009     5<br />
Mon Jul 27 19:12:32 CEST 2009     7<br />
Mon Jul 27 19:12:37 CEST 2009     13<br />
Mon Jul 27 19:12:42 CEST 2009     9<br />
Mon Jul 27 19:12:47 CEST 2009     8<br />
Mon Jul 27 19:12:52 CEST 2009     50<br />
Mon Jul 27 19:12:57 CEST 2009     88<br />
Mon Jul 27 19:13:02 CEST 2009     101<br />
Mon Jul 27 19:13:07 CEST 2009     120<br />
Mon Jul 27 19:13:12 CEST 2009     129<br />
Mon Jul 27 19:13:17 CEST 2009     135<br />
Mon Jul 27 19:13:23 CEST 2009     145<br />
Mon Jul 27 19:13:28 CEST 2009     150<br />
Mon Jul 27 19:13:33 CEST 2009     163<br />
Mon Jul 27 19:13:38 CEST 2009     167<br />
Mon Jul 27 19:13:43 CEST 2009     175<br />
Mon Jul 27 19:13:48 CEST 2009     180<br />
Mon Jul 27 19:13:53 CEST 2009     183<br />
Mon Jul 27 19:13:58 CEST 2009     190<br />
Mon Jul 27 19:14:03 CEST 2009     202<br />
Mon Jul 27 19:14:08 CEST 2009     204<br />
Mon Jul 27 19:14:13 CEST 2009     204<br />
Mon Jul 27 19:14:18 CEST 2009     203<br />
Mon Jul 27 19:14:23 CEST 2009     206<br />
Mon Jul 27 19:14:28 CEST 2009     207<br />
Mon Jul 27 19:14:33 CEST 2009     211<br />
Mon Jul 27 19:14:38 CEST 2009     216<br />
Mon Jul 27 19:14:43 CEST 2009     218<br />
Mon Jul 27 19:14:48 CEST 2009     220<br />
Mon Jul 27 19:14:53 CEST 2009     222<br />
Mon Jul 27 19:14:58 CEST 2009     227<br />
Mon Jul 27 19:15:03 CEST 2009     229<br />
Mon Jul 27 19:15:08 CEST 2009     228<br />
Mon Jul 27 19:15:13 CEST 2009     229<br />
Mon Jul 27 19:15:18 CEST 2009     232<br />
Mon Jul 27 19:15:23 CEST 2009     234<br />
Mon Jul 27 19:15:28 CEST 2009     234<br />
Mon Jul 27 19:15:34 CEST 2009     237<br />
Mon Jul 27 19:15:39 CEST 2009     240<br />
Mon Jul 27 19:15:44 CEST 2009     241<br />
Mon Jul 27 19:15:49 CEST 2009     243<br />
Mon Jul 27 19:15:54 CEST 2009     244<br />
Mon Jul 27 19:15:59 CEST 2009     244<br />
Mon Jul 27 19:16:04 CEST 2009     246<br />
Mon Jul 27 19:16:09 CEST 2009     245<br />
Mon Jul 27 19:16:14 CEST 2009     246<br />
Mon Jul 27 19:16:19 CEST 2009     247<br />
Mon Jul 27 19:16:24 CEST 2009     246<br />
Mon Jul 27 19:16:29 CEST 2009     244<br />
Mon Jul 27 19:16:34 CEST 2009     250<br />
Mon Jul 27 19:16:39 CEST 2009     253<br />
Mon Jul 27 19:16:44 CEST 2009     252<br />
Mon Jul 27 19:16:49 CEST 2009     253<br />
Mon Jul 27 19:16:54 CEST 2009     256<br />
Mon Jul 27 19:16:59 CEST 2009     258<br />
Mon Jul 27 19:17:04 CEST 2009     260<br />
Mon Jul 27 19:17:09 CEST 2009     264<br />
Mon Jul 27 19:17:14 CEST 2009     262<br />
Mon Jul 27 19:17:19 CEST 2009     273<br />
Mon Jul 27 19:17:24 CEST 2009     301<br />
Mon Jul 27 19:17:30 CEST 2009     301<br />
Mon Jul 27 19:17:35 CEST 2009     301<br />
Mon Jul 27 19:17:40 CEST 2009     301<br />
</code></p>
<p>It is important to notice these are the values after some tuning on my side already and running a special iptables filter, which I describe in a later articel. They where worse before. The current limit are 300 active connections which lead to following entries by courier.</p>
<p><code><br />
Jul 27 19:17:23 mail courieresmtpd: 300 maximum active connections.<br />
Jul 27 19:18:24 mail courieresmtpd: 300 maximum active connections.<br />
Jul 27 19:21:14 mail courieresmtpd: 300 maximum active connections.<br />
</code></p>
<p>At this point my monitoring reports that the SMTP service is not reachable as courier does not handle new connections. After some minutes the wave got past my server and the active connections go down again and the monitoring reports the the SMTP service is up again.</p>
<p>You may ask why I don&#8217;t just raise the limit of 300 active connections? Because with 300 connections I need already 1GB of RAM only for SMTP stuff. This is because courier forks for every connection a &#8220;small&#8221; process which handles it. Almost all of the connecting servers are in a DNS RBL so it should be quite easy to just block them. But it is not that easy.</p>
<p><strong>First Idea:</strong><br />
courier is waiting a log time before it closes a connection after sending the 5xx verdict. So I looked at a way to reduce the time, by setting following values in seconds:</p>
<p><code><br />
root@mail:~# cat /etc/courier/esmtptimeout<br />
30<br />
root@mail:~# cat /etc/courier/esmtptimeoutconnect<br />
30<br />
root@mail:~# cat /etc/courier/esmtptimeoutdata<br />
180<br />
root@mail:~# cat /etc/courier/esmtptimeouthelo<br />
30<br />
</code></p>
<p>Which are quit on the lower end and they helped a little bit, specially to get down to normal business after the top of the spam wave has past. But the wave still maxed my system out.</p>
<p><strong>Second Idea:</strong></p>
<p>I thought at first why does courier wait for the spammer to send a mail before sending a 5xx as the IP is on a DNS RBL? A special process could just drop the connections after doing asynchron DNS RBL check and sending a 5xx to the other server.</p>
<p>Sam Varshavchik the lead programmer of courier told me following:</p>
<blockquote><p>
Except that dropping a connection at this point has proven not to work, as soon as you run into a real mail server, but a broken one that interprets an immediately disconnected connection as an invitation to reconnect immediately.
</p></blockquote>
<p>So ok not good and he said following about my idea to drop the connection &#8230;.</p>
<blockquote><p>
And watch your bandwidth get eaten up by a broken server that&#8217;s trying to dump on you a load of spam, using multiple connections which immediatly try to reconnect as soon as you drop them.</p>
<p>The most reliable way to reject unwanted mail is by RCPT TO. This is why even when it&#8217;s a blacklisted sender, it doesn&#8217;t get rejected until it actually sends an RCPT TO. Which means that you have to fully implement SMTP up to that point.</p>
<p>This means that you&#8217;ll wind up with a model of using a monolithic, huge process for all SMTP connections, or a single lightweight process per connection.
</p></blockquote>
<p>So this is the starting point of my search for a solution to fix my problem with the exception of replacing courier as MTA at this point (if there is nothing really better out there) and specially no hardware upgrades. I hope some readers have some ideas (please write comments!). I had already one which invokes iptables, but it is a more complex setup which I&#8217;ll write in the next article of this series.</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/173/the-search-for-reduced-spam-load-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Firefox Addons I use and recommend</title>
		<link>http://robert.penz.name/163/firefox-addons-i-use-and-recommend/</link>
		<comments>http://robert.penz.name/163/firefox-addons-i-use-and-recommend/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 11:24:30 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=163</guid>
		<description><![CDATA[I thought I share the Firefox plugins I use and which make me use Firefox in the first place. Without these plugins Firefox would be just a browser of many and the webkit browsers render faster on my Kubuntu .  So these Plugins make the difference for me. NoScript: Without I feel &#8220;unsafe&#8221; in the [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I share the Firefox plugins I use and which make me use Firefox in the first place. Without these plugins Firefox would be just a browser of many and the webkit browsers render faster on my Kubuntu <img src='http://robert.penz.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .  So these Plugins make the difference for me.</p>
<ul>
<li><strong><a href="https://addons.mozilla.org/en-US/firefox/addon/722">NoScript</a>:</strong> Without I feel &#8220;unsafe&#8221; in the internet. It allows JavaScript, Java and other executable content to run only from trusted domains of your choice. You can activate JS only for a session also, so you&#8217;re save again next time.</li>
<li><strong><a href="https://addons.mozilla.org/en-US/firefox/addon/4703">Cookie Monster</a>:</strong> This plugin allows me to manage my cookies. I can set from which domains I accept which kind. e.g. I accept cookies only for the session from a domain if it is needed.</li>
<li><strong><a href="http://www.xmarks.com/">Xmarks</a>:</strong> I use this plugin to sync my bookmarks between systems and also to have a backup at all times of them. You can also use it do sync/save your stored passworts securely.  You can also use your own server.</li>
<li><strong><a href="http://www.downloadhelper.net/">DownloadHelper</a>:</strong> You never know when you would like to download a flash movie or something like this onto your PC. This plugin will enable you to do so.</li>
<li><strong><a href="http://abcdefu.wordpress.com/2009/06/09/introducing-yip-an-unified-notification-system-for-the-web/">Yip</a>:</strong> If you&#8217;re using something like <a href="https://www.meebo.com/">meebo.com</a> for instant messaging you surely would like to get notifications of a new message also outside the tab in your browser, as it mostlikely happens that you&#8217;re working with an other program or in an other tab. If so, take a look at Yip, as its supports  supports Fluid and Prism which cover the large majority (100%?) of currently implemented notifications.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/163/firefox-addons-i-use-and-recommend/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>All SSL Sites are fake-able with new real world MD5 collision attack [Update]</title>
		<link>http://robert.penz.name/149/all-ssl-sites-are-fake-able-with-new-real-world-md5-collision-attack/</link>
		<comments>http://robert.penz.name/149/all-ssl-sites-are-fake-able-with-new-real-world-md5-collision-attack/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 16:12:57 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[IT Security]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=149</guid>
		<description><![CDATA[You really should look at this video of a presentation (in English) which was just given at the 25C3 in Berlin. Alexander Sotirov, Marc Stevens and Jacob Appelbaum have generated an intermediate certificate which is &#8220;signed&#8221; by RapidSSL which is shipped with all browsers. As there is no limit which certificates can be signed by [...]]]></description>
			<content:encoded><![CDATA[<p>You really should look at this <a href="http://81.163.130.141/streamdump/saal1/Tag4-Saal1-Slot15:15--ID3023-making_the_theoretical_possible-Main-2008-12-30T15:15:03+0100.ogm">video</a> of a presentation (in English) which was just given at the <a href="http://events.ccc.de/congress/2008/">25C3</a> in Berlin. Alexander Sotirov, Marc Stevens and Jacob Appelbaum have generated an intermediate certificate which is &#8220;signed&#8221; by <a href="http://www.rapidssl.com/">RapidSSL</a> which is shipped with all browsers. As there is no limit which certificates can be signed by which CA, it is possible to fake any SSL site!!</p>
<p><strong>The good news is that they don&#8217;t indent to release the private key.</strong></p>
<p>Basically they took the 2007 shown theoretical MD5 collision attack and improved it and the major part: They took it onto a real world CA. They used the RapidSSL CA as they still use MD5 and have a nice automatic and predictable generation process. It takes always 6 seconds to generate one and they increment the serial number of the certificates by one every time. As for the collision attack it is important to previously know the timestamp and the serial number. Both was not that hard at RapidSSL, specially if you did some requests at Sunday night. Here is the link to a <a href="http://www.win.tue.nl/hashclash/rogue-ca/">document</a> from the guys describing it more in detail.</p>
<p>Ok, this time it maybe the good guys but who can prove to me that nobody else did this, as it cost them under 700 Euros. And removing all MD5 signing CAs is also not a solution at this point of time as up to 30% of the websites are signed by such CA&#8217;s. And for server admins it is also almost impossible to find CAs which report which hash functions they use. And there is still the revoke list problem, I&#8217;ve written <a href="http://robert.penz.name/66/the-fallout-of-the-debian-openssl-security-problem/">previously</a> (and also <a href="http://robert.penz.name/67/dns-based-revoke-lists/">here</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/149/all-ssl-sites-are-fake-able-with-new-real-world-md5-collision-attack/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Home partition encryption with LUKS under Linux</title>
		<link>http://robert.penz.name/145/home_partition_encryption_with_luks_under_linux/</link>
		<comments>http://robert.penz.name/145/home_partition_encryption_with_luks_under_linux/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 17:00:15 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=145</guid>
		<description><![CDATA[I&#8217;m often asked how I crypt my notebooks. I normally crypt only my home partition and sometimes (more on servers in remote locations, than on notebooks) the swap partition. I use for this Linux Unified Key Setup (Luks), as it allows up to 8 passwords for a partition and you can change them without reformatting [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m often asked how I crypt my notebooks. I normally crypt only my home partition and sometimes (more on servers in remote locations, than on notebooks) the swap partition. I use for this <a href="http://luks.endorphin.org/">Linux Unified Key Setup (Luks)</a>, as it allows up to 8 passwords for a partition and you can change them without reformatting the partition. It also stores the used encryption method so you can use it also for encrypting external hard disks and you don&#8217;t need to keep track which encryption algorithms you used for it.</p>
<p>First you install your notebook with a swap and a root partition, but leave space for a /home partition. After the installation is finished you create the partition e.g. with cfdisk or fdisk. You need to restart your system after creating a new partition. In my example I call it /dev/sda3. Now you can tell cryptsetp (which you need to install on Ubuntu with apt-get install cryptsetup, reboot after installing it if the setup does not work) to create a container with following command</p>
<p><code>cryptsetup --cipher aes-cbc-essiv:sha256 --key-size 128 luksFormat /dev/sda3</code></p>
<p>After you did this, you need to open the container with </p>
<p><code>cryptsetup luksOpen /dev/sda3 home</code></p>
<p>Now you can format the container:</p>
<p><code>mkfs.ext3 -m 0 /dev/mapper/home</code></p>
<p><strong>ps:</strong> -m 0 means that no blocks are reserved for root, as it is our home partition.</p>
<p>Now you need to go to the console of your system (<code>ALT-CTRL-F1</code>) and login there and stop the X server (log off before that <img src='http://robert.penz.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ). On Ubuntu you do this by calling <code>/etc/init.d/gdm stop</code>  on Kubuntu <code>/etc/init.d/kdm stop</code>.</p>
<p>Now you can mount the new partition on a temporary location and copy your home directory over.</p>
<p><code>mount /dev/mapper/home /mnt/<br />
cp -a /home/* /mnt/.<br />
</code></p>
<p>Now we need to unmount it and close the crypto container.</p>
<p><code>umount /mnt/<br />
cryptsetup luksClose home<br />
</code></p>
<p>Now we need to configure the system that it is launched at the boot time. Add following line to <code>/etc/crypttab</code>:</p>
<p><code>home    /dev/sda3       none    luks</code></p>
<p>and in your <code>/etc/fstab</code> you add following:</p>
<p><code>/dev/mapper/home        /home   ext3     noatime,nodiratime        0       0</code></p>
<p>Now everything is done. Reboot your system and you will be prompted for the password of your home partition. If you don&#8217;t enter it your system will use the &#8220;old&#8221; home directory. </p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/145/home_partition_encryption_with_luks_under_linux/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Clicky Web Analytics the alternative to Google Analytics</title>
		<link>http://robert.penz.name/139/clicky-web-analytics-the-alternative-to-google-analytics/</link>
		<comments>http://robert.penz.name/139/clicky-web-analytics-the-alternative-to-google-analytics/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 13:06:45 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=139</guid>
		<description><![CDATA[I&#8217;m using Google Analytics for some time now, it basically works, but it has some short comings like that the reports do only get updated every 24h, or that it is not able to track bound links without extra work on my side. But the most import part is that I don&#8217;t want that google [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using Google Analytics for some time now, it basically works, but it has some short comings like that the reports do only get updated every 24h, or that it is not able to track bound links without extra work on my side. But the most import part is that I don&#8217;t want that google knows everything. So I started to look for a valid alternative. I tried some local installable open source tools but decided to go with an other <a href="http://en.wikipedia.org/wiki/Software_as_a_service">SaaS.</a> If you&#8217;re using <a href="http://noscript.net/">NoScript</a> for your Firefox you might know it already I started using <a href="http://www.getclicky.com/">Click Web Analytics</a>. Take a look at this screenshot, it looks like most web 2.0 sites, simple, clean design with a white background.</p>
<p style="text-align: center;"><img class="size-full wp-image-140" title="clicky_web1" src="http://robert.penz.name/wp-content/uploads/2008/12/click_web1.gif" alt="" width="350" height="200" /></p>
<p>Whats nice is that you can do a real time campaign and goal tracking and that you can track every visitor who comes to your web site and if they accept cookies all their history. This will show you which power cookies gives website providers. You should really think to disable them or remove them on every start of your browser. But as long the most users have activated it I will also take a look at it and have a nice show case for people I talk over this.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-141 aligncenter" title="clicky_web2" src="http://robert.penz.name/wp-content/uploads/2008/12/clicky_web2.gif" alt="" width="350" height="200" /></p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/139/clicky-web-analytics-the-alternative-to-google-analytics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>No SWAP Partition, Journaling Filesystems, &#8230; on a SSD?</title>
		<link>http://robert.penz.name/137/no-swap-partition-journaling-filesystem-on-a-ssd/</link>
		<comments>http://robert.penz.name/137/no-swap-partition-journaling-filesystem-on-a-ssd/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 10:05:19 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=137</guid>
		<description><![CDATA[I&#8217;m going to get an Asus Eee PC 901go, which has a Solid State Disk (SSD) instead of a normal hard disk (HD). As you know me I&#8217;ll remove the installed Linux and install my own Kubuntu. I soon started to look at the best way to install my Kubuntu and I found following recommendations [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to get an Asus Eee PC 901go, which has a Solid State Disk (SSD) instead of a normal hard disk (HD). As you know me I&#8217;ll remove the installed Linux and install my own Kubuntu. I soon started to look at the best way to install my Kubuntu and I found following recommendations copy and pasted on various sites:</p>
<ol>
<li> Never choose to use a journaling file system on the SSD partitions</li>
<li> Never use a swap partition on the SSD</li>
<li> Edit your new installation fstab to mount the SSD partitions &#8220;noatime&#8221;</li>
<li> Never log messages or error log to the SSD</li>
</ol>
<p>Are they really true or just copy and pasted without knowledge.  But first why should that be a problem at all? SSDs have limited write (erase) cycles. Depending on the type of flash-memory cells they will fail after only 10,000 (MLC) or up to 100,000 write cycles for <a href="http://www.computerworld.com/action/article.do?command=viewArticleBasic&amp;taxonomyName=Storage&amp;articleId=9112065&amp;taxonomyId=19&amp;pageNumber=1">SLC</a>, while high endurance cells may have an endurance of 1–5 million write cycles. Special file systems (e.g. jffs, jffs2, logfs for Linux) or firmware designs can mitigate this problem by spreading writes over the entire device (so-called wear leveling), rather than rewriting files in place. So theoretically there is a problem but what means this in practice?</p>
<p>The experts at storagesearch.com have written an article <a href="http://www.storagesearch.com/ssdmyths-endurance.html">SSD Myths and Legends &#8211; &#8220;write endurance&#8221;</a> which takes a closer look at this topic. They provide following simple calculation:</p>
<ul>
<li>One SSD, 2 million cycles, 80MB/sec write speed (that are the fastest SSDs on the market),  64GB (entry level for enterprise SSDs &#8211; if you get more the life time increases)</li>
<li>They assume perfect wear leveling which means they need to fill the disk 2 million times to get to the write endurance limit.</li>
<li>2 million (write endurance) x 64G (capacity) divided by 80M bytes / sec gives the endurance limited life in seconds.</li>
<li>That&#8217;s a meaningless number &#8211; which needs to be divided by seconds in an hour, hours in a day etc etc to give&#8230;</li>
</ul>
<p>The end result is <strong>51 years</strong>!</p>
<p>Ok thats for servers, but what is with my Asus 901go?</p>
<ul>
<li>Lets take the benchmark values from <a href="http://www.eeepc.it/en/recensione-eeepc-901go-hardware-benchmark">eeepc.it</a> which makes it to a max of 50 MByte/sec. But this is a sequential write, which is not the write profile of our atime, swap, journaling&#8230; stuff. That are typically 4k Blocks which leads to 2 MByte/sec. (Side node: T<span>he EeePC 901go mount the same disk of SSD <a title="EeePC S101" href="http://www.eeepc.it/en/tag/eeepc-s101/">&#8216;EeePC S101,</a> to be precise model ASUS SATA JM-chip Samsung S41.)</span></li>
<li>We stay also with the 2 million cycles and assume a 16GB SSD</li>
<li>With 50 MByte/sec we get <strong>20 years!</strong></li>
<li>With 2 MByte/sec we get <strong>519 years!</strong></li>
<li>And even if we reduce the write cycles to 100.000 and write with 2 MByte/sec all the time we&#8217;re at<strong> 26 years!!<br />
</strong></li>
</ul>
<p>And all this is with writing all the time, even ext3 does write the journal only every 30 secs if no data needs to be written. <strong>So the recommendation to safeguard SSDs, as the can not write that often is bullshit!!</strong></p>
<p>So lets take a closer look at the 4 points at the beginning of this blog post.</p>
<ol>
<li><em> Never choose to use a journaling file system on the SSD partitions:</em> <strong>Bullshit, you&#8217;re just risking data security. Stay with ext3.</strong></li>
<li> Never use a swap partition on the SSD: <strong>If you&#8217;ve enough space on your SSD use a SWAP partition it will not be written onto it until there is to less RAM, in which case you can run a program/perform a task which otherwise you could not. And take a look at this </strong><a href="http://kerneltrap.org/node/3202"><strong>article</strong></a><strong>.</strong></li>
<li> Edit your new installation fstab to mount the SSD partitions &#8220;noatime&#8221;: <strong>That is a good idea if all the programs work with this setting as this will speedup your read performace, specially with many small files. Take also a look at nodiratime.</strong></li>
<li> Never log messages or error log to the SSD. <strong>Come on, how many log entries do you get on a netbook? That is not an email server with &gt; 1000 log lines per second. </strong></li>
</ol>
<p>Please write a comment if you disagree or even agree with my blog post. Thx!</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/137/no-swap-partition-journaling-filesystem-on-a-ssd/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>secure file uploading with scponly</title>
		<link>http://robert.penz.name/131/secure-file-uploading-with-scponly/</link>
		<comments>http://robert.penz.name/131/secure-file-uploading-with-scponly/#comments</comments>
		<pubDate>Sun, 23 Nov 2008 19:10:56 +0000</pubDate>
		<dc:creator>robert</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[IT Security]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://robert.penz.name/?p=131</guid>
		<description><![CDATA[If you&#8217;re administrating Linux servers you may need someone or some script to copy files onto your server. You could now install a special service like a ftp server or you could use a normal ssh user for this. The problem with the first is that you need an extra service which adds complexity and [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re administrating Linux servers you may need someone or some script to copy files onto your server. You could now install a special service like a ftp server or you could use a normal ssh user for this. The problem with the first is that you need an extra service which adds complexity and also provides an additional attack vector. The problem with the normal ssh user is that you provide the script or user functionally on your server that he/it does not need for his/its work (like exciting programs) &#8211; this is never a good idea. </p>
<p>What I recommend for this is a program called scponly. It does basically what the name says, if a ssh user has it set as its shell the user is only able to use scp functionality. Ubuntu and Debian provide a package for it but you should read an article like this <a href="http://sublimation.org/scponly/wiki/index.php/Install">one</a> to know to setup it up securely. For example it is a really bad idea to allow the user to write into his home directory as a writable home directory will make it possible for the user to subvert scponly by modifying ssh configuration files.</p>
]]></content:encoded>
			<wfw:commentRss>http://robert.penz.name/131/secure-file-uploading-with-scponly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

