<?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>SoftLayer Blog &#187; administration</title>
	<atom:link href="http://blog.softlayer.com/tag/administration/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.softlayer.com</link>
	<description>A Behind the Scenes Look at the Best Hosting Provider in the World</description>
	<lastBuildDate>Wed, 22 May 2013 17:40:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>iptables Tips and Tricks: CSF Configuration</title>
		<link>http://blog.softlayer.com/2013/iptables-tips-and-tricks-csf-configuration/</link>
		<comments>http://blog.softlayer.com/2013/iptables-tips-and-tricks-csf-configuration/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 18:10:39 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[APF]]></category>
		<category><![CDATA[blocking]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[CSF]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[iptab]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[technical]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=10812</guid>
		<description><![CDATA[In our last &#8220;iptables Tips and Tricks&#8221; installment, we talked about Advanced Policy Firewall (APF) configuration, so it should come as no surprise that in this installment, we&#8217;re turning our attention to ConfigServer Security &#38; Firewall (CSF). Before we get started, you should probably run through the list of warnings I include at the top [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.softlayer.com/2013/iptables-tips-and-tricks-apf-advanced-policy-firewall-configuration/">our last &#8220;iptables Tips and Tricks&#8221; installment</a>, we talked about Advanced Policy Firewall (APF) configuration, so it should come as no surprise that in this installment, we&#8217;re turning our attention to <a href="http://configserver.com/cp/csf.html">ConfigServer Security &amp; Firewall</a> (CSF). Before we get started, you should probably run through the list of warnings I include at the top of the APF blog post and make sure you have your Band-Aid ready in case you need it.</p>
<p>To get the ball rolling, we need to download CSF and install it on our server. In this post, we&#8217;re working with a CentOS 6.0 32-bit server, so our (root) terminal commands would look like this to download and install CSF:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.configserver.com<span style="color: #000000; font-weight: bold;">/</span>free<span style="color: #000000; font-weight: bold;">/</span>csf.tgz <span style="color: #666666; font-style: italic;">#Download CSF using wget.</span>
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf csf.tgz <span style="color: #666666; font-style: italic;">#Unpack it.</span>
$ yum <span style="color: #c20cb9; font-weight: bold;">install</span> perl-libwww-perl <span style="color: #666666; font-style: italic;">#Make sure perl modules are installed ...</span>
$ yum <span style="color: #c20cb9; font-weight: bold;">install</span> perl-Time-HiRes  <span style="color: #666666; font-style: italic;">#Otherwise it will generate an error.</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> csf
$ .<span style="color: #000000; font-weight: bold;">/</span>install.sh <span style="color: #666666; font-style: italic;">#Install CSF.</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#MAKE SURE YOU HAVE YOUR BAND-AID READY</span>
&nbsp;
$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>csf start <span style="color: #666666; font-style: italic;">#Start CSF. (Note: You can also use '$ service csf start')</span></pre></div></div>

<p>Once you start CSF, you can see a list of the default rules that load at startup. CSF defaults to a DROP policy:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ iptables <span style="color: #660033;">-nL</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> policy
Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy DROP<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Chain FORWARD <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy DROP<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Chain OUTPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy DROP<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Don&#8217;t ever run &#8220;<code>iptables -F</code>&#8221; unless you want to lock yourself out. In fact, you might want to add &#8220;This server is running CSF &#8211; do not run &#8216;iptables -F&#8217;&#8221;  to your <code>/etc/motd</code>, just as a reminder/warning to others.</p>
<p>CSF loads on startup by default. This means that if you get locked out, a simple reboot probably won&#8217;t fix the problem. Runlevels 2, 3, 4, and 5 are all on:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ chkconfig <span style="color: #660033;">--list</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> csf
csf             <span style="color: #000000;">0</span>:off   <span style="color: #000000;">1</span>:off   <span style="color: #000000;">2</span>:on    <span style="color: #000000;">3</span>:on    <span style="color: #000000;">4</span>:on    <span style="color: #000000;">5</span>:on    <span style="color: #000000;">6</span>:off</pre></div></div>

<p>Some features of CSF will not work unless you have certain iptables modules installed. I believe they are installed by default in CentOS, but if you custom-built your iptables, they might not all be installed. Run this script to see if all modules are installed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf<span style="color: #000000; font-weight: bold;">/</span>csftest.pl
Testing ip_tables<span style="color: #000000; font-weight: bold;">/</span>iptable_filter...OK
Testing ipt_LOG...OK
Testing ipt_multiport<span style="color: #000000; font-weight: bold;">/</span>xt_multiport...OK
Testing ipt_REJECT...OK
Testing ipt_state<span style="color: #000000; font-weight: bold;">/</span>xt_state...OK
Testing ipt_limit<span style="color: #000000; font-weight: bold;">/</span>xt_limit...OK
Testing ipt_recent...OK
Testing xt_connlimit...OK
Testing ipt_owner<span style="color: #000000; font-weight: bold;">/</span>xt_owner...OK
Testing iptable_nat<span style="color: #000000; font-weight: bold;">/</span>ipt_REDIRECT...OK
Testing iptable_nat<span style="color: #000000; font-weight: bold;">/</span>ipt_DNAT...OK
&nbsp;
RESULT: csf should <span style="color: #000000; font-weight: bold;">function</span> on this server</pre></div></div>

<p>As I mentioned, this is the default iptables installation on a minimal CentOS 6.0 image, so chances are good that these modules are already installed on your system. It never hurts to check, though.</p>
<h3>The CSF Configuration File</h3>
<p>The primary CSF configuration is stored in the well-documented <code>/etc/csf/csf.conf</code> file. CSF is <em>extremely</em> configurable, so there are a lot of options to read over. Let&#8217;s take a look over some of the more important features:</p>
<p><span id="more-10812"></span></p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Testing</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">TESTING = <span style="color: #ff0000;">&quot;1&quot;</span>
TESTING_INTERVAL = <span style="color: #ff0000;">&quot;5&quot;</span></pre></div></div>

<p>This TESTING cron job runs every &#8220;5&#8243; minutes so you don&#8217;t lock yourself out when you&#8217;re testing your rules. When you are satisfied with your rules (and confident that you won&#8217;t lock yourself out), you can set TESTING to &#8220;0&#8243;.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Globally Allowed Ports</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Allow incoming TCP ports</span>
TCP_IN = <span style="color: #ff0000;">&quot;20,21,22,25,53,80,110,143,443,465,587,993,995&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Allow outgoing TCP ports</span>
TCP_OUT = <span style="color: #ff0000;">&quot;20,21,22,25,53,80,110,113,443&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Allow incoming UDP ports</span>
UDP_IN = <span style="color: #ff0000;">&quot;20,21,53&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Allow outgoing UDP ports</span>
<span style="color: #666666; font-style: italic;"># To allow outgoing traceroute add 33434:33523 to this list</span>
UDP_OUT = <span style="color: #ff0000;">&quot;20,21,53,113,123&quot;</span></pre></div></div>

<p style="margin-bottom:0; padding-bottom:5px;"><strong>Incoming Ping Requests</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Allow incoming PING</span>
ICMP_IN = <span style="color: #ff0000;">&quot;1&quot;</span></pre></div></div>

<p>Allowing ping is usually a good option for diagnostic purposes, so I don&#8217;t recommend turning it off. Disallowing ping is an example of &#8220;security through obscurity,&#8221; and it will not typically dissuade your attackers.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Ethernet Device</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ETH_DEVICE = <span style="color: #ff0000;">&quot;&quot;</span>
ETH6_DEVICE = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>Here, you can configure iptables to ONLY use one Ethernet adapter. You might want to only guard your public network adapter in some situations.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>IP Limit in Permanent &#8220;Deny&#8221; File</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DENY_IP_LIMIT = <span style="color: #ff0000;">&quot;200&quot;</span></pre></div></div>

<p>A higher number here will obviously screen out more IP addresses in <code>csf.deny</code>, but higher numbers also may cause slowdowns.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>IP Limit in Temporary &#8220;Deny&#8221; File</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DENY_TEMP_IP_LIMIT = <span style="color: #ff0000;">&quot;100&quot;</span></pre></div></div>

<p>Similar to DENY_IP_LIMIT, the DENY_TEMP_IP_LIMIT represents the maximum number of IPs that can be stored in the temporary ban list.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>SMTP Blocking</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SMTP_BLOCK = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>When set to &#8220;1&#8243;, SMTP_BLOCK does not completely block outbound SMTP, but it does block it for most users. This will prevent malicious scripts and compromised users from making outbound connections from unauthorized mail clients on the server. SMTP_BLOCK doesn&#8217;t stop those scripts from running, but it does stop them from functioning. Mail sent through the proper channels will still be delivered normally.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Allowing SMTP on localhost</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SMTP_ALLOWLOCAL = <span style="color: #ff0000;">&quot;1&quot;</span></pre></div></div>

<p style="margin-bottom:0; padding-bottom:5px;"><strong>Custom Mail Port Designation</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SMTP_PORTS = <span style="color: #ff0000;">&quot;25,465,587&quot;</span></pre></div></div>

<p style="margin-bottom:0; padding-bottom:5px;"><strong>Allowing SMTP Access to Users/Groups</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SMTP_ALLOWUSER = <span style="color: #ff0000;">&quot;&quot;</span>
SMTP_ALLOWGROUP = <span style="color: #ff0000;">&quot;mail,mailman&quot;</span></pre></div></div>

<p style="margin-bottom:0; padding-bottom:5px;"><strong>SYN Flood Protection</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SYNFLOOD = <span style="color: #ff0000;">&quot;0&quot;</span>
SYNFLOOD_RATE = <span style="color: #ff0000;">&quot;100/s&quot;</span>
SYNFLOOD_BURST = <span style="color: #ff0000;">&quot;150&quot;</span></pre></div></div>

<p>Per the documentation, you should only enable SYN flood protection (SYNFLOOD= &#8220;1&#8243;) if you are currently under a SYN flood attack.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Concurrent Connections Limit</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CONNLIMIT = <span style="color: #ff0000;">&quot;22;5,80;20&quot;</span>
PORTFLOOD = <span style="color: #ff0000;">&quot;22;tcp;5;300,80;tcp;20;5</span></pre></div></div>

<p>These options allow you to add customized DoS protection. CONNLIMIT handles the number of concurrent connections, and in this example, we&#8217;re limiting port 22 to 5 connections and port 80 to 20 connections.</p>
<p>PORTFLOOD on deals with connections per second. In this example, we&#8217;re limiting the TCP connection on port 22 to 5 connections/second with a quiet period of 300 seconds before the connection is unblocked. Additonally, we&#8217;re limiting the TCP connection on port 80 to 20 connections/second with a quiet period of 5 seconds before the connection is unblocked.</p>
<p>Check the <code>readme.txt</code> file for more information about the syntax.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Logging to Syslog</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">SYSLOG = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>When enabled, this option logs lfd (Login Failure Daemon) messages to syslog as well as to <code>/var/log/lfd.log</code>.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Dropping v. Rejecting Packets</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DROP = <span style="color: #ff0000;">&quot;DROP&quot;</span></pre></div></div>

<p>This configuration allows you to either DROP or REJECT packets. REJECT tells the sender that the packet has been blocked by the firewall. DROP just drops the packet and does not send a response. I like DROP better for regular use, but REJECT might be more helpful if you need to diagnose a connectivity issue.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Logging Dropped Connections</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DROP_LOGGING = <span style="color: #ff0000;">&quot;1&quot;</span></pre></div></div>

<p>This option logs dropped connections to syslog. I don&#8217;t see any reason to turn this off unless your hard drive is getting full.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Port Exceptions When Logging Dropped Connections</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DROP_NOLOG = <span style="color: #ff0000;">&quot;67,68,111,113,135:139,445,500,513,520&quot;</span></pre></div></div>

<p>These ports are specifically blocked from being logged either to conserve hard drive space or make the log file easier to read.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>&#8220;Watch Mode&#8221;</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">WATCH_MODE = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>If you are ever stuck trying to troubleshoot a large ruleset, you might consider turning this option on. You can use it to track the actions to watched IP addresses to see where they are getting blocked or accepted.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Login Failure Daemon Alert</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_ALERT_TO = <span style="color: #ff0000;">&quot;&quot;</span>
LF_ALERT_FROM = <span style="color: #ff0000;">&quot;&quot;</span>
LF_ALERT_SMTP = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>You can specify an email address to report errors from the Login Failure Daemon, which tracks and automatically blocks brute force login attempts.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Permanent Blocks and NetBlocks</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_PERMBLOCK = <span style="color: #ff0000;">&quot;1&quot;</span>
LF_PERMBLOCK_INTERVAL = <span style="color: #ff0000;">&quot;86400&quot;</span>
LF_PERMBLOCK_COUNT = <span style="color: #ff0000;">&quot;4&quot;</span>
LF_PERMBLOCK_ALERT = <span style="color: #ff0000;">&quot;1&quot;</span>
LF_NETBLOCK = <span style="color: #ff0000;">&quot;0&quot;</span>
LF_NETBLOCK_INTERVAL = <span style="color: #ff0000;">&quot;86400&quot;</span>
LF_NETBLOCK_COUNT = <span style="color: #ff0000;">&quot;4&quot;</span>
LF_NETBLOCK_CLASS = <span style="color: #ff0000;">&quot;C&quot;</span>
LF_NETBLOCK_ALERT = <span style="color: #ff0000;">&quot;1&quot;</span></pre></div></div>

<p>These settings control the permanent block and netblock blocking. You probably don&#8217;t need to touch these settings, but you might want some additional security or less security depending on your company needs. If something gets permablocked, it will require your intervention to clear it, which might create downtime for your clients. Likewise, if a legitimate IP address happens to be part of a netblock which has an attacking IP address on it, it will get blocked if you have that feature turned on. A class C network encompasses 256 IP addresses. You can set this to class B or A, but that could block thousands or millions of IP addresses, respectively. Unless you find yourself under constant attack, I would advise you to leave that LF_NETBLOCK off.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Additional Protection During Updates</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Safe Chain Update. If enabled, all dynamic update chains (GALLOW*, GDENY*,</span>
<span style="color: #666666; font-style: italic;"># SPAMHAUS, DSHIELD, BOGON, CC_ALLOW, CC_DENY, ALLOWDYN*) will create a new</span>
<span style="color: #666666; font-style: italic;"># chain when updating, and insert it into the relevant LOCALINPUT/LOCALOUTPUT</span>
<span style="color: #666666; font-style: italic;"># chain, then flush and delete the old dynamic chain and rename the new chain.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This prevents a small window of opportunity opening when an update occurs and</span>
<span style="color: #666666; font-style: italic;"># the dynamic chain is flushed for the new rules.</span>
SAFECHAINUPDATE = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>Activating this option will increase your system resource usage and will require more rules to be running at one time, but it provides an additional layer of protection during updates. Without this option turned on, your rules will be flushed for a short amount of time, leaving your server vulnerable.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Multi-Server Deployment Options</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_GLOBAL = <span style="color: #ff0000;">&quot;0&quot;</span>
GLOBAL_ALLOW = <span style="color: #ff0000;">&quot;&quot;</span>
GLOBAL_DENY = <span style="color: #ff0000;">&quot;&quot;</span>
GLOBAL_IGNORE = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>Like APF, you can configure global lists for multiple server deployments. You&#8217;ll need to specify a URL of the text file with the IP addresses for the global lists.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>SPAMHAUSE Blocklist</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_SPAMHAUS = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>This option enables the SPAMHAUS blocklist. Specify the number of seconds between refreshes. Recommended setting is 86400 (1 day).</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Blocking TOR Exit IP Addresses</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_TOR = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>Enabling this option will block TOR exit IP addresses. If you are not familiar with <a href="https://www.torproject.org/">TOR</a>, it is a completely anonymous proxy network. This could block some legitimate users who are trying to protect their anonymity, so I would recommend only turning this on if you are already under attack from a TOR exit address.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Blocking Bogon Addresses</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_BOGON = <span style="color: #ff0000;">&quot;0&quot;</span>
LF_BOGON_URL = <span style="color: #ff0000;">&quot;http://www.cymru.com/Documents/bogon-bn-agg.txt&quot;</span>
LF_BOGON_SKIP = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>Blocking bogon addresses (addresses that should not be possible) is usually a good decision. To enable, set the number of seconds between refreshes. I recommend enabling this option and setting the refresh at 86400 (1 day). If you do so, be sure to add your private network adapters to the skip list.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Country-Specific Access to Your Server</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CC_DENY = <span style="color: #ff0000;">&quot;&quot;</span>
CC_ALLOW = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>With these options, you can block or allow entire countries from accessing your server. To do so, enter the country codes in a comma separated list. Even though this generates a lot of additional rules, it&#8217;s valuable to some sysadmins.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CC_ALLOW_FILTER = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>Alternatively, you can set your server to exclusively accept traffic from a list of country codes. All other countries not listed will have their traffic dropped. There are many other settings related to these options that I don&#8217;t have time to cover in this blog.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Blocking Login Failures</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_TRIGGER = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>This enables blocking of login failures (per service). There are a lot of great customization options in this section.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Scanning Directories for Malicious Files</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_DIRWATCH = <span style="color: #ff0000;">&quot;300&quot;</span></pre></div></div>

<p>This feature scans <code>/tmp</code> and <code>/dev/shm</code> for potentially malicious files and alerts you to their presence based on the interval you designate. You can also have CSF automatically quarantine malicious files with this option:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_DIRWATCH_DISABLE = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p style="margin-bottom:0; padding-bottom:5px;"><strong>Distributed Attack Protection</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LF_DISTATTACK = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>By enabling this option, you activate additional protection against distributed attacks.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Blocking Based on Abusive Email Usage</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LT_POP3D = <span style="color: #ff0000;">&quot;0&quot;</span>
LT_IMAPD = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>If a user checks email too many times per hour (more than the non-zero value specified), the user&#8217;s IP address is blocked.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Email Alert Following Block</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">LT_EMAIL_ALERT = <span style="color: #ff0000;">&quot;1&quot;</span></pre></div></div>

<p>This will send you email when something is blocked. I&#8217;d recommend leaving it on.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Blocking IP Addresses Based on Number of Connections</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CT_LIMIT = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>This feature tracks connections and blocks the IP if the number of connections is too high. Use caution because if you enable this option and set this value too low, it will block legitimate traffic.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Application-Level Protection</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PT_LIMIT = <span style="color: #ff0000;">&quot;60&quot;</span></pre></div></div>

<p>This feature provides application level protection against malicious scripts that take a long time to execute.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Blocking Port Scanners</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PS_INTERVAL = <span style="color: #ff0000;">&quot;300&quot;</span>
PS_LIMIT = <span style="color: #ff0000;">&quot;10&quot;</span></pre></div></div>

<p style="margin-bottom:0; padding-bottom:5px;"><strong>Enabling HTML User Interface for CSF</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">UI = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>CSF has a built-in HTML user interface. You can enable this by setting UI = &#8220;1&#8243;. There are a list of prerequisites for this option in the <code>readme.txt</code>.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Notifying Blocked IP Addresses</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">MESSENGER = <span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>This option will notify blocked IP addresses when they have been blocked by the firewall.</p>
<p style="margin-bottom:0; padding-bottom:5px;"><strong>Port Knocking</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PORTKNOCKING = <span style="color: #ff0000;">&quot;&quot;</span></pre></div></div>

<p>CSF supports port knocking, which is a technique that provides an additional layer of security. See <a href="http://www.portknocking.org/">http://www.portknocking.org/</a> for details. </p>
<h3>Allow and Deny Lists</h3>
<p>As we walked through the CSF configuration file, you saw that I referenced the <code>csf.deny</code> file, so it should come as no surprise that CSF also includes <code>csf.allow</code> to customize &#8220;allow&#8221; rules as well. If you are familiar with APF, these files have a very similar syntax &#8230; Each entry is made up of the same four components: <code>protocol|flow|port|IP</code>. The only real difference being that APF uses the colon as a delimiter while CSF uses the pipe:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#APF Version</span>
tcp:<span style="color: #000000; font-weight: bold;">in</span>:<span style="color: #007800;">d</span>=<span style="color: #000000;">48000</span>_48020:<span style="color: #007800;">s</span>=10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#CSF Version</span>
tcp<span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000; font-weight: bold;">in</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #007800;">d</span>=<span style="color: #000000;">48000</span>_48020<span style="color: #000000; font-weight: bold;">|</span><span style="color: #007800;">s</span>=10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span></pre></div></div>

<p>Fortunately, replacing your colon with a pipe is a minimally invasive procedure that can be automated with a tool like vi.</p>
<h3>CSF Command Line Tool</h3>
<p>The command line tool for CSF is much more robust than the one for APF:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ csf <span style="color: #660033;">--help</span>
csf: v5.79 <span style="color: #7a0874; font-weight: bold;">&#40;</span>cPanel<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
ConfigServer Security <span style="color: #000000; font-weight: bold;">&amp;</span> Firewall
<span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000;">2006</span>-<span style="color: #000000;">2013</span>, Way to the Web Limited <span style="color: #7a0874; font-weight: bold;">&#40;</span>http:<span style="color: #000000; font-weight: bold;">//</span>www.configserver.com<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
Usage: <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>csf <span style="color: #7a0874; font-weight: bold;">&#91;</span>option<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>value<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Option              Meaning
-h, <span style="color: #660033;">--help</span>          Show this message
-l, <span style="color: #660033;">--status</span>        List<span style="color: #000000; font-weight: bold;">/</span>Show iptables configuration
-l6, <span style="color: #660033;">--status6</span>      List<span style="color: #000000; font-weight: bold;">/</span>Show ip6tables configuration
-s, <span style="color: #660033;">--start</span>         Start firewall rules
-f, <span style="color: #660033;">--stop</span>          Flush<span style="color: #000000; font-weight: bold;">/</span>Stop firewall rules <span style="color: #7a0874; font-weight: bold;">&#40;</span>Note: lfd may restart csf<span style="color: #7a0874; font-weight: bold;">&#41;</span>
-r, <span style="color: #660033;">--restart</span>       Restart firewall rules
-q, <span style="color: #660033;">--startq</span>        Quick restart <span style="color: #7a0874; font-weight: bold;">&#40;</span>csf restarted by lfd<span style="color: #7a0874; font-weight: bold;">&#41;</span>
-sf, <span style="color: #660033;">--startf</span>       Force CLI restart regardless of LF_QUICKSTART setting
-a, <span style="color: #660033;">--add</span> ip        Allow an IP and add to <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.allow
-ar, <span style="color: #660033;">--addrm</span> ip     Remove an IP from <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.allow and delete rule
-d, <span style="color: #660033;">--deny</span> ip       Deny an IP and add to <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.deny
-dr, <span style="color: #660033;">--denyrm</span> ip    Unblock an IP and remove from <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.deny
-df, <span style="color: #660033;">--denyf</span>        Remove and unblock all entries <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.deny
-g, <span style="color: #660033;">--grep</span> ip       Search the iptables rules <span style="color: #000000; font-weight: bold;">for</span> an IP match <span style="color: #7a0874; font-weight: bold;">&#40;</span>incl. CIDR<span style="color: #7a0874; font-weight: bold;">&#41;</span>
-t, <span style="color: #660033;">--temp</span>          Displays the current list of temp IP entries and their TTL
-tr, <span style="color: #660033;">--temprm</span> ip    Remove an IPs from the temp IP ban and allow list
-td, <span style="color: #660033;">--tempdeny</span> ip ttl <span style="color: #7a0874; font-weight: bold;">&#91;</span>-p port<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-d direction<span style="color: #7a0874; font-weight: bold;">&#93;</span>
                    Add an IP to the temp IP ban list. ttl is how long to
                    blocks <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>default:seconds, can use one suffix of h<span style="color: #000000; font-weight: bold;">/</span>m<span style="color: #000000; font-weight: bold;">/</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>.
                    Optional port. Optional direction of block can be one of:
                    <span style="color: #000000; font-weight: bold;">in</span>, out or inout <span style="color: #7a0874; font-weight: bold;">&#40;</span>default:<span style="color: #000000; font-weight: bold;">in</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
-ta, <span style="color: #660033;">--tempallow</span> ip ttl <span style="color: #7a0874; font-weight: bold;">&#91;</span>-p port<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-d direction<span style="color: #7a0874; font-weight: bold;">&#93;</span>
                    Add an IP to the temp IP allow list <span style="color: #7a0874; font-weight: bold;">&#40;</span>default:inout<span style="color: #7a0874; font-weight: bold;">&#41;</span>
-tf, <span style="color: #660033;">--tempf</span>        Flush all IPs from the temp IP entries
-cp, <span style="color: #660033;">--cping</span>        PING all members <span style="color: #000000; font-weight: bold;">in</span> an lfd Cluster
-cd, <span style="color: #660033;">--cdeny</span> ip     Deny an IP <span style="color: #000000; font-weight: bold;">in</span> a Cluster and add to <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.deny
-ca, <span style="color: #660033;">--callow</span> ip    Allow an IP <span style="color: #000000; font-weight: bold;">in</span> a Cluster and add to <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.allow
-cr, <span style="color: #660033;">--crm</span> ip       Unblock an IP <span style="color: #000000; font-weight: bold;">in</span> a Cluster and remove from <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf.deny
-cc, <span style="color: #660033;">--cconfig</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>name<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>value<span style="color: #7a0874; font-weight: bold;">&#93;</span>
                    Change configuration option <span style="color: #7a0874; font-weight: bold;">&#91;</span>name<span style="color: #7a0874; font-weight: bold;">&#93;</span> to <span style="color: #7a0874; font-weight: bold;">&#91;</span>value<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">in</span> a Cluster
-cf, <span style="color: #660033;">--cfile</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Send <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">in</span> a Cluster to <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>csf<span style="color: #000000; font-weight: bold;">/</span>
-crs, <span style="color: #660033;">--crestart</span>    Cluster restart csf and lfd
-w, <span style="color: #660033;">--watch</span> ip      Log SYN packets <span style="color: #000000; font-weight: bold;">for</span> an IP across iptables chains
-m, <span style="color: #660033;">--mail</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>addr<span style="color: #7a0874; font-weight: bold;">&#93;</span>   Display Server Check <span style="color: #000000; font-weight: bold;">in</span> HTML or email to <span style="color: #7a0874; font-weight: bold;">&#91;</span>addr<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">if</span> present
-lr, <span style="color: #660033;">--logrun</span>       Initiate Log Scanner report via lfd
-c, <span style="color: #660033;">--check</span>         Check <span style="color: #000000; font-weight: bold;">for</span> updates to csf but <span style="color: #000000; font-weight: bold;">do</span> not upgrade
-u, <span style="color: #660033;">--update</span>        Check <span style="color: #000000; font-weight: bold;">for</span> updates to csf and upgrade <span style="color: #000000; font-weight: bold;">if</span> available
<span style="color: #660033;">-uf</span>                 Force an update of csf
-x, <span style="color: #660033;">--disable</span>       Disable csf and lfd
-e, <span style="color: #660033;">--enable</span>        Enable csf and lfd <span style="color: #000000; font-weight: bold;">if</span> previously disabled
-v, <span style="color: #660033;">--version</span>       Show csf version</pre></div></div>

<p>The command line tool will also tell you if the testing mode is enabled (which is a very useful feature). If TESTING were enabled, we&#8217;d see this line at the bottom of the output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*</span>WARNING<span style="color: #000000; font-weight: bold;">*</span> TESTING mode is enabled - <span style="color: #000000; font-weight: bold;">do</span> not forget to disable it <span style="color: #000000; font-weight: bold;">in</span> the configuration</pre></div></div>

<p>Did you make it all the way through?! Great! I know it&#8217;s a lot to take in, but it&#8217;s not terribly complicated when we break it down and understand how each piece works. Next time, I&#8217;ll be back with some tips on integrating CSF into cPanel. </p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2013/iptables-tips-and-tricks-csf-configuration/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>iptables Tips and Tricks: APF (Advanced Policy Firewall) Configuration</title>
		<link>http://blog.softlayer.com/2013/iptables-tips-and-tricks-apf-advanced-policy-firewall-configuration/</link>
		<comments>http://blog.softlayer.com/2013/iptables-tips-and-tricks-apf-advanced-policy-firewall-configuration/#comments</comments>
		<pubDate>Tue, 29 Jan 2013 22:40:14 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[allow]]></category>
		<category><![CDATA[APF]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[deny]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[rules]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[traffic]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=10543</guid>
		<description><![CDATA[Let&#8217;s talk about APF. APF &#8212; Advanced Policy Firewall &#8212; is a policy-based iptables firewall system that provides simple, powerful control over your day-to-day server security. It might seem intimidating to be faced with all of the features and configuration tools in APF, but this blog should put your fears to rest. APF is an [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s talk about APF. APF &mdash; <a href="http://www.rfxn.com/projects/advanced-policy-firewall/">Advanced Policy Firewall</a> &mdash; is a policy-based iptables firewall system that provides simple, powerful control over your day-to-day server security. It might seem intimidating to be faced with all of the features and configuration tools in APF, but this blog should put your fears to rest. </p>
<p>APF is an iptables wrapper that works alongside iptables and extends its functionality. I personally don&#8217;t use iptables wrappers, but I have a lot of experience with them, and I&#8217;ve seen that they <em>do</em> offer some additional features that streamline policy management. For example, by employing APF, you&#8217;ll get several simple on/off toggles (set via configuration files) that make some complex iptables configurations available without extensive coding requirements. The flip-side of a wrapper&#8217;s simplicity is that you aren&#8217;t directly in control of the iptables commands, so if something breaks it might take longer to diagnose and repair. Before you add a wrapper like APF, be sure that you know what you are getting into. Here are a few points to consider:</p>
<ul>
<li>Make sure that what you&#8217;re looking to use adds a feature you need but cannot easily incorporate with iptables on its own.</li>
<li>You need to know how to effectively enable and disable the iptables wrapper (the correct way &#8230; read the manual!), and you should always have a trusted failsafe iptables ruleset handy in the unfortunate event that something goes horribly wrong and you need to disable the wrapper.
<li>Learn about the basic configurations and rule changes you can apply via the command line. You&#8217;ll need to understand the way your wrapper takes rules because it may differ from the way iptables handles rules.</li>
<li>You can&#8217;t manually configure your iptables rules once you have your wrapper in place (or at least you <em>shouldn&#8217;t</em>).</li>
<li>Be sure to know how to access your server via the IPMI management console so that if you completely lock yourself out beyond repair, you can get back in. You might even go so far as to have a script or set of instructions ready for tech support to run, in the event that you can&#8217;t get in via the management console.</li>
</ul>
<p><strong>TL;DR: Have a Band-Aid ready!</strong></p>
<h3>APF Configuration</h3>
<p>Now that you have been sufficiently advised about the potential challenges of using a wrapper (and you&#8217;ve got your Band-Aid ready), we can check out some of the useful APF rules that make iptables administration a lot easier. Most of the configuration for APF is in <code>conf.apf</code>. This file handles the default behavior, but not necessarily the specific blocking rules, and when we make any changes to the configuration, we&#8217;ll need to restart the APF service for the changes to take effect.</p>
<p>Let&#8217;s jump into <code>conf.apf</code> and break down what we see. The first code snippit is fairly self-explanatory. It&#8217;s another way to make sure you <a href="http://blog.softlayer.com/2012/iptables-tips-and-tricks-not-locking-yourself-out/">don&#8217;t lock yourself out</a> of your server as you are making configuration changes and testing them:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># !!! Do not leave set to (1) !!!</span>
<span style="color: #666666; font-style: italic;"># When set to enabled; 5 minute cronjob is set to stop the firewall. Set</span>
<span style="color: #666666; font-style: italic;"># this off (0) when firewall is determined to be operating as desired.</span>
<span style="color: #007800;">DEVEL_MODE</span>=<span style="color: #ff0000;">&quot;1&quot;</span></pre></div></div>

<p>The next configuration options we&#8217;ll look at are where you can make quick high-level changes if you find that legitimate traffic is being blocked and you want to make APF a little more lenient:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># This controls the amount of violation hits an address must have before it</span>
<span style="color: #666666; font-style: italic;"># is blocked. It is a good idea to keep this very low to prevent evasive</span>
<span style="color: #666666; font-style: italic;"># measures. The default is 0 or 1, meaning instant block on first violation.</span>
<span style="color: #007800;">RAB_HITCOUNT</span>=<span style="color: #ff0000;">&quot;1&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This is the amount of time (in seconds) that an address gets blocked for if</span>
<span style="color: #666666; font-style: italic;"># a violation is triggered, the default is 300s (5 minutes).</span>
<span style="color: #007800;">RAB_TIMER</span>=<span style="color: #ff0000;">&quot;300&quot;</span>
<span style="color: #666666; font-style: italic;"># This allows RAB to 'trip' the block timer back to 0 seconds if an address</span>
<span style="color: #666666; font-style: italic;"># attempts ANY subsiquent communication while still on the inital block period.</span>
<span style="color: #007800;">RAB_TRIP</span>=<span style="color: #ff0000;">&quot;1&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This controls if the firewall should log all violation hits from an address.</span>
<span style="color: #666666; font-style: italic;"># The use of LOG_DROP variable set to 1 will override this to force logging.</span>
<span style="color: #007800;">RAB_LOG_HIT</span>=<span style="color: #ff0000;">&quot;1&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This controls if the firewall should log all subsiqent traffic from an address</span>
<span style="color: #666666; font-style: italic;"># that is already blocked for a violation hit, this can generate allot of logs.</span>
<span style="color: #666666; font-style: italic;"># The use of LOG_DROP variable set to 1 will override this to force logging.</span>
<span style="color: #007800;">RAB_LOG_TRIP</span>=<span style="color: #ff0000;">&quot;0&quot;</span></pre></div></div>

<p>Next, we have an option to adjust ICMP flood protection. This protection should be useful against some forms of DoS attacks, and the associated rules show up in your INPUT chain:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Set a reasonable packet/time ratio for ICMP packets, exceeding this flow</span>
<span style="color: #666666; font-style: italic;"># will result in dropped ICMP packets. Supported values are in the form of:</span>
<span style="color: #666666; font-style: italic;"># pkt/s (packets/seconds), pkt/m (packets/minutes)</span>
<span style="color: #666666; font-style: italic;"># Set value to 0 for unlimited, anything above is enabled.</span>
<span style="color: #007800;">ICMP_LIM</span>=<span style="color: #ff0000;">&quot;30/s&quot;</span></pre></div></div>

<p>If you wanted to add more ports to block for p2p traffic (which will show up in the P2P chain), you&#8217;ll update this code:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># A common set of known Peer-To-Peer (p2p) protocol ports that are often</span>
<span style="color: #666666; font-style: italic;"># considered undesirable traffic on public Internet servers. These ports</span>
<span style="color: #666666; font-style: italic;"># are also often abused on web hosting servers where clients upload p2p</span>
<span style="color: #666666; font-style: italic;"># client agents for the purpose of distributing or downloading pirated media.</span>
<span style="color: #666666; font-style: italic;"># Format is comma separated for single ports and an underscore separator for</span>
<span style="color: #666666; font-style: italic;"># ranges (4660_4678).</span>
<span style="color: #007800;">BLK_P2P_PORTS</span>=<span style="color: #ff0000;">&quot;1214,2323,4660_4678,6257,6699,6346,6347,6881_6889,6346,7778&quot;</span></pre></div></div>

<p>The next few lines let you designate the ports that you want to have closed at all times. They will be blocked for INPUT and OUTPUT chains:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># These are common Internet service ports that are understood in the wild</span>
<span style="color: #666666; font-style: italic;"># services you would not want logged under normal circumstances. All ports</span>
<span style="color: #666666; font-style: italic;"># that are defined here will be implicitly dropped with no logging for</span>
<span style="color: #666666; font-style: italic;"># TCP/UDP traffic inbound or outbound. Format is comma separated for single</span>
<span style="color: #666666; font-style: italic;"># ports and an underscore separator for ranges (135_139).</span>
<span style="color: #007800;">BLK_PORTS</span>=<span style="color: #ff0000;">&quot;135_139,111,513,520,445,1433,1434,1234,1524,3127&quot;</span></pre></div></div>

<p>The next important section to look at deals with conntrack. If you get &#8220;conntrack full&#8221; errors, this is where you&#8217;d increase the allowed connections. It&#8217;s not uncommon to need more connections than the default, so if you need to adjust that value, you&#8217;d do it here:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># This is the maximum number of &quot;sessions&quot; (connection tracking entries) that</span>
<span style="color: #666666; font-style: italic;"># can be handled simultaneously by the firewall in kernel memory. Increasing</span>
<span style="color: #666666; font-style: italic;"># this value too high will simply waste memory - setting it too low may result</span>
<span style="color: #666666; font-style: italic;"># in some or all connections being refused, in particular during denial of</span>
<span style="color: #666666; font-style: italic;"># service attacks.</span>
<span style="color: #007800;">SYSCTL_CONNTRACK</span>=<span style="color: #ff0000;">&quot;65536&quot;</span></pre></div></div>

<p>We&#8217;ve talked about the ports we want closed at all times, so it only makes sense that we&#8217;d specify which ports we want open for all interfaces:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Common inbound (ingress) TCP ports</span>
<span style="color: #007800;">IG_TCP_CPORTS</span>=<span style="color: #ff0000;">&quot;22&quot;</span>
<span style="color: #666666; font-style: italic;"># Common inbound (ingress) UDP ports</span>
<span style="color: #007800;">IG_UDP_CPORTS</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #666666; font-style: italic;"># Common outbound (egress) TCP ports</span>
<span style="color: #007800;">EG_TCP_CPORTS</span>=<span style="color: #ff0000;">&quot;21,25,80,443,43&quot;</span>
<span style="color: #666666; font-style: italic;"># Common outbound (egress) UDP ports</span>
<span style="color: #007800;">EG_UDP_CPORTS</span>=<span style="color: #ff0000;">&quot;20,21,53&quot;</span></pre></div></div>

<p>And when we want a special port allowance for specific users, we can declare it easily. For example, if we want port 22 open for user ID 0, we&#8217;d use this code:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Allow outbound access to destination port 22 for uid 0</span>
<span style="color: #007800;">EG_TCP_UID</span>=<span style="color: #ff0000;">&quot;0:22&quot;</span></pre></div></div>

<p>The next few sections on <code>Remote Rule Imports</code> and <code>Global Trust</code> are a little more specialized, and I encourage you to read a little more about them (since there&#8217;s so much to them and not enough space to cover them here on the blog). An important feature of APF is that it imports block lists from outside sources to keep you safe from some attackers, so the <code>Remote Rule Imports</code> can prove to be very useful. The <code>Global Trust</code> section is incredibly useful for multi-server deployments of APF. Here, you can set up your global allow/block lists and have them all pull from a central location so that you can make a single update to the source and have the update propogated to all servers in your configuration. These changes are synced to the <code>glob_allow/deny.rules</code> files, and they will be downloaded (and overwritten) on a regular basis from your specified source, so don&#8217;t make any manual edits in <code>glob_allow/deny.rules</code>.</p>
<p>As you can see, <code>apf.conf</code> is no joke. It has a lot of stuff going on, but it&#8217;s very straightforward and documented well. Once we&#8217;ve set up apf.conf with the configurations we need, it&#8217;s time to look at the more focused <code>allow_hosts.rules</code> and <code>deny_hosts.rules</code> files. These <code>.rules</code> files are where where you put your typical firewall rules in place. If there&#8217;s one piece of advice I can give you about these configurations, it would be to check if your traffic is already allowed or blocked. Having multiple rules that do the same thing (possibly in different places) is confusing and potentially dangerous. </p>
<p>The <code>deny_hosts.rules</code> configuration will look just like <code>allow_hosts.rules</code>, but it&#8217;s performing the opposite function. Let&#8217;s check out an <code>allow_hosts.rules</code> configuration that will allow the Nimsoft service to function:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tcp:<span style="color: #000000; font-weight: bold;">in</span>:<span style="color: #007800;">d</span>=<span style="color: #000000;">48000</span>_48020:<span style="color: #007800;">s</span>=10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>
tcp:out:<span style="color: #007800;">d</span>=<span style="color: #000000;">48000</span>_48020:<span style="color: #007800;">d</span>=10.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span></pre></div></div>

<p>The format is somewhat simplistic, but the file gives a little more context in the comments:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># The trust rules can be made in advanced format with 4 options</span>
<span style="color: #666666; font-style: italic;"># (proto:flow:port:ip);</span>
<span style="color: #666666; font-style: italic;"># 1) protocol: [packet protocol tcp/udp]</span>
<span style="color: #666666; font-style: italic;"># 2) flow in/out: [packet direction, inbound or outbound]</span>
<span style="color: #666666; font-style: italic;"># 3) s/d=port: [packet source or destination port]</span>
<span style="color: #666666; font-style: italic;"># 4) s/d=ip(/xx) [packet source or destination address, masking supported]</span>
<span style="color: #666666; font-style: italic;"># Syntax:</span>
<span style="color: #666666; font-style: italic;"># proto:flow:[s/d]=port:[s/d]=ip(/mask)</span></pre></div></div>

<p>APF also uses <code>ds_hosts.rules</code> to load the DShield.org blocklist, and I assume the <code>ecnshame_hosts.rules</code> does something similar (can&#8217;t find much information about it), so you won&#8217;t need to edit these files manually. Additionally, you probably don&#8217;t need to make any changes to <code>log.rules</code>, unless you want to make changes to what exactly you log. As it stands, it logs certain dropped connections, which should be enough. Also, it might be worth noting that this file is a script, not a configuration file.</p>
<p>The last two configuration files are the <code>preroute.rules</code> and <code>postroute.rules</code> that (unsurprisingly) are used to make routing changes. If you have been following my articles, this corresponds to the <a href="http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/">iptables chains for PREROUTING and POSTROUTING</a> where you would do things like port forwarding and other advanced configuration that you probably don&#8217;t want to do in most cases.</p>
<h3>APF Command Line Management</h3>
<p>As I mentioned in the &#8220;points to consider&#8221; at the top of this post, it&#8217;s important to learn the changes you can perform from the command line, and APF has some very useful command line tools:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>server<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># apf --help</span>
APF version <span style="color: #000000;">9.7</span> <span style="color: #000000; font-weight: bold;">&lt;</span>apf<span style="color: #000000; font-weight: bold;">@</span>r-fx.org<span style="color: #000000; font-weight: bold;">&gt;</span>
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>C<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2002</span>-<span style="color: #000000;">2011</span>, R-fx Networks <span style="color: #000000; font-weight: bold;">&lt;</span>proj<span style="color: #000000; font-weight: bold;">@</span>r-fx.org<span style="color: #000000; font-weight: bold;">&gt;</span>
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>C<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2011</span>, Ryan MacDonald <span style="color: #000000; font-weight: bold;">&lt;</span>ryan<span style="color: #000000; font-weight: bold;">@</span>r-fx.org<span style="color: #000000; font-weight: bold;">&gt;</span>
This program may be freely redistributed under the terms of the GNU GPL
&nbsp;
usage <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apf <span style="color: #7a0874; font-weight: bold;">&#91;</span>OPTION<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #660033;">-s</span><span style="color: #000000; font-weight: bold;">|</span>--start ......................... load all firewall rules
<span style="color: #660033;">-r</span><span style="color: #000000; font-weight: bold;">|</span>--restart ....................... stop <span style="color: #7a0874; font-weight: bold;">&#40;</span>flush<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;</span> reload firewall rules
<span style="color: #660033;">-f</span><span style="color: #000000; font-weight: bold;">|</span>--stop........ .................. stop <span style="color: #7a0874; font-weight: bold;">&#40;</span>flush<span style="color: #7a0874; font-weight: bold;">&#41;</span> all firewall rules
<span style="color: #660033;">-l</span><span style="color: #000000; font-weight: bold;">|</span>--list .......................... list all firewall rules
<span style="color: #660033;">-t</span><span style="color: #000000; font-weight: bold;">|</span>--status ........................ output firewall status log
<span style="color: #660033;">-e</span><span style="color: #000000; font-weight: bold;">|</span>--refresh ....................... refresh <span style="color: #000000; font-weight: bold;">&amp;</span> resolve dns names <span style="color: #000000; font-weight: bold;">in</span> trust rules
<span style="color: #660033;">-a</span> HOST CMT<span style="color: #000000; font-weight: bold;">|</span>--allow HOST COMMENT ... add host <span style="color: #7a0874; font-weight: bold;">&#40;</span>IP<span style="color: #000000; font-weight: bold;">/</span>FQDN<span style="color: #7a0874; font-weight: bold;">&#41;</span> to allow_hosts.rules and
                                     immediately load new rule into firewall
<span style="color: #660033;">-d</span> HOST CMT<span style="color: #000000; font-weight: bold;">|</span>--deny HOST COMMENT .... add host <span style="color: #7a0874; font-weight: bold;">&#40;</span>IP<span style="color: #000000; font-weight: bold;">/</span>FQDN<span style="color: #7a0874; font-weight: bold;">&#41;</span> to deny_hosts.rules and
                                     immediately load new rule into firewall
<span style="color: #660033;">-u</span><span style="color: #000000; font-weight: bold;">|</span>--remove HOST ................... remove host from <span style="color: #7a0874; font-weight: bold;">&#91;</span>glob<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span>_hosts.rules
                                     and immediately remove rule from firewall
<span style="color: #660033;">-o</span><span style="color: #000000; font-weight: bold;">|</span>--ovars ......................... output all configuration options</pre></div></div>

<p>You can use these command line tools to turn your firewall on and off, add allowed or blocked hosts and display troubleshooting information. These commands are very easy to use, but if you want more fine-tuned control, you&#8217;ll need to edit the configuration files directly (as we looked at above).</p>
<p>I know it seems like a lot of information, but to a large extent, that&#8217;s all you need to know to get started with APF. Take each section slowly and understand what each configuration file is doing, and you&#8217;ll master APF in no time at all.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2013/iptables-tips-and-tricks-apf-advanced-policy-firewall-configuration/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Trouble with Open DNS Resolvers</title>
		<link>http://blog.softlayer.com/2012/the-trouble-with-open-dns-resolvers/</link>
		<comments>http://blog.softlayer.com/2012/the-trouble-with-open-dns-resolvers/#comments</comments>
		<pubDate>Fri, 02 Nov 2012 16:30:55 +0000</pubDate>
		<dc:creator>Ryan Carter</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[abuse]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[amplification]]></category>
		<category><![CDATA[article]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[DDoS]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[DNS resolvers]]></category>
		<category><![CDATA[network providers]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[open resolvers]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=9642</guid>
		<description><![CDATA[In the last couple of days, there&#8217;s been a bit of buzz about &#8220;open DNS resolvers&#8221; and DNS amplification DDoS attacks, and SoftLayer&#8217;s name has been brought up a few times. In a blog post on October 30, CloudFlare explained DNS Amplification DDoS attacks and reported the geographic and network sources of open DNS resolvers [...]]]></description>
			<content:encoded><![CDATA[<p>In the last couple of days, there&#8217;s been a bit of buzz about &#8220;open DNS resolvers&#8221; and DNS amplification DDoS attacks, and SoftLayer&#8217;s name has been brought up a few times. In a blog post on October 30, CloudFlare <a href="http://blog.cloudflare.com/deep-inside-a-dns-amplification-ddos-attack">explained DNS Amplification DDoS attacks</a> and reported the geographic and network sources of open DNS resolvers that were contributing to a 20Gbps attack on their network. SoftLayer&#8217;s AS numbers (SOFTLAYER and the legacy THEPLANET-AS number) show up on the top ten &#8220;worst offenders&#8221; list, and Dan Goodin contacted us to get a comment for a follow-up piece on Ars Technica &mdash; <a href="http://arstechnica.com/security/2012/10/meet-the-network-operators-helping-fuel-the-spike-in-big-ddos-attacks/">Meet the network operators helping to fuel the spike in big DDoS attacks</a>.</p>
<p>While the content of that article is less sensationalized than the title, there are still a few gaps to fill about when it comes to how SoftLayer is actually involved in the big picture (*SPOILER ALERT* We aren&#8217;t &#8220;helping to fuel the spike in big DDoS attacks&#8221;). The CloudFlare blog and the Ars Technica post presuppose that the presence of open recursive DNS resolvers is a sign of negligence on the part of the network provider at best and maliciousness at worst, and that&#8217;s not the case.</p>
<p>The majority of SoftLayer&#8217;s infrastructure is made up of self-managed dedicated and cloud servers. Customers who rent those servers on a monthly basis have unrestricted access to operate their servers in any way they&#8217;d like as long as that activity meets our acceptable use policy. Some of our largest customers are hosting resellers who provide that control to their customers who can then provide that control to their own customers. And if 23 million hostnames reside on the SoftLayer network, you can bet that we&#8217;ve got a lot of users hosting their DNS on SoftLayer infrastructure. Unfortunately, it&#8217;s easier for those customers and customers-of-customers and customers-of-customers-of-customers to use &#8220;defaults&#8221; instead of looking for, learning and implementing &#8220;best practices.&#8221;</p>
<p>It&#8217;s all too common to find those DNS resolvers open and ultimately vulnerable to DNS amplification attacks, and whenever our team is alerted to that vulnerability on our network, we make our customers aware of it. In turn, they may pass the word down the customer-of-customer chain to get to the DNS owner. It&#8217;s usually not a philosophical question about whether DNS resolvers should be open for the greater good of the Internet &#8230; It&#8217;s a question of whether the DNS owner has any idea that their &#8220;configuration&#8221; is vulnerable to be abused in this way.</p>
<p>SoftLayer&#8217;s network operations, abuse and support teams have tools that flag irregular and potentially abusive traffic coming from any server on our network, and we take immediate action when we find a problem or are alerted to one by someone who sends details to <a href="mailto:abuse@softlayer.com">abuse@softlayer.com</a>. The challenge we run into is that flagging obvious abusive behavior from an active DNS server is a bit of a cat-and-mouse game &#8230; Attackers cloak their activity in normal traffic. Instead of sending a huge amount of traffic from a single domain, they send a marginal amount of traffic from a large number of machines, and the &#8220;abusive&#8221; traffic is nearly impossible for even the DNS owner to differentiate from &#8220;regular&#8221; traffic.</p>
<p>CloudFlare effectively became a <a href="http://en.wikipedia.org/wiki/Honeypot_%28computing%29">honeypot</a>, and they caught a distributed DNS amplification DoS attack. The results they gathered are extremely valuable to teams like mine at SoftLayer, so if they go the next step to actively contact the abuse channel for each of the network providers in their list, I hope that each of the other providers will jump on that information as I know my team will.</p>
<p>If you have a DNS server on the SoftLayer network, and you&#8217;re not sure whether it&#8217;s configured to prevent it from being used for these types of attacks, our support team is happy to help you out. For those of you interested in doing a little DNS homework to learn more, Google&#8217;s Developer Network has an awesome overview of <a href="https://developers.google.com/speed/public-dns/docs/security">DNS security threats and mitigations</a> which gives an overview of potential attacks and preventative measures you can take. If you&#8217;re just looking for an easy way to close an open recursor, scroll to the bottom of <a href="http://blog.cloudflare.com/deep-inside-a-dns-amplification-ddos-attack">CloudFlare&#8217;s post</a>, and follow their quick guide.</p>
<p>If, on the other hand, you have your own DNS server and you don&#8217;t want to worry about all of this configuration or administration, SoftLayer operates private DNS resolvers that are limited to our announced IP space. Feel free to use ours instead!</p>
<p>-Ryan</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2012/the-trouble-with-open-dns-resolvers/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>iptables Tips and Tricks &#8211; Not Locking Yourself Out</title>
		<link>http://blog.softlayer.com/2012/iptables-tips-and-tricks-not-locking-yourself-out/</link>
		<comments>http://blog.softlayer.com/2012/iptables-tips-and-tricks-not-locking-yourself-out/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 16:41:30 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[protect]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=7401</guid>
		<description><![CDATA[The iptables tool is one of the simplest, most powerful tools you can use to protect your server. We&#8217;ve covered port redirection, rule processing and troubleshooting in previous installments to this &#8220;Tips and Tricks&#8221; series, but what happens when iptables turns against you and locks you out of your own system? Getting locked out of [...]]]></description>
			<content:encoded><![CDATA[<p>The <code>iptables</code> tool is one of the simplest, most powerful tools you can use to protect your server. We&#8217;ve covered <a href="http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/">port redirection</a>, <a href="http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/">rule processing</a> and <a href="http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/">troubleshooting</a> in previous installments to this &#8220;Tips and Tricks&#8221; series, but what happens when iptables turns against you and locks you out of your own system? </p>
<p>Getting locked out of a production server can cost both time and money, so it&#8217;s worth your time to avoid this. If you follow the correct procedures, you can safeguard yourself from being firewalled off of your server. Here are seven helpful tips to help you keep your sanity and prevent you from locking yourself out.</p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 1: Keep a safe ruleset handy.</strong></p>
<p style="margin-top:0;padding-top:0;">If you are starting with a working ruleset, or even if you are trying to troubleshoot an existing ruleset, take a backup of your iptables configuration before you ever start working on it.</p>
<p><code>iptables-save > /root/iptables-safe</code></p>
<p>Then if you do something that prevents your website from working, you can quickly restore it.</p>
<p><code>iptables-restore < /root/iptables-safe</code></p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 2: Create a cron script that will reload to your safe ruleset every minute during testing.</strong></p>
<p style="margin-top:0;padding-top:0;">This was pointed out to my by a friend who swears by this method. Just write a quick bash script and set a cron entry that will reload it back to the safe set every minute. You'll have to test quickly, but it will keep you from getting locked out.</p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 3: Have the IPMI KVM ready.</strong></p>
<p style="margin-top:0;padding-top:0;">SoftLayer-pod servers* are equipped with some sort of remote access device. Most of them have a KVM console. You will want to have your VPN connection set up, connected and the KVM window up. You can't paste to and from the KVM, so SSH is typically easier to work with, but it will definitely cut down on the downtime if something does go wrong.</p>
<p><em>*This may not apply to servers that were originally provisioned under another company name.</em></p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 4: Try to avoid generic rules.</strong></p>
<p style="margin-top:0;padding-top:0;">The more criteria you specify in the rule, the less chance you will have of locking yourself out. I would liken this to a pie. A specific rule is a very thin slice of the pie.</p>
<p><code>iptables -A INPUT -p tcp --dport 22 -s 10.0.0.0/8 -d 123.123.123.123 -j DROP</code></p>
<p>But if you block port 22 from any to any, it's a very large slice.</p>
<p><code>iptables -A INPUT -p tcp --dport 22 -j DROP</code></p>
<p>There are plenty of ways that you can be more specific. For example, using "<code>-i eth0</code>" will limit the processing to a single NIC in your server. This way, it will not apply the rule to <code>eth1</code>.</p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 5: Whitelist your IP address at the top of your ruleset.</strong></p>
<p style="margin-top:0;padding-top:0;">This may make testing more difficult unless you have a secondary offsite test server, but this is a very effective method of not getting locked out.</p>
<p><code>iptables -I INPUT -s &lt;your IP&gt; -j ACCEPT</code></p>
<p>You need to put this as the FIRST rule in order for it to work properly ("<code>-I</code>" inserts it as the first rule, whereas "<code>-A</code>" appends it to the end of the list).</p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 6: Know and understand all of the rules in your current configuration.</strong></p>
<p style="margin-top:0;padding-top:0;">Not making the mistake in the first place is half the battle. If you understand the inner workings behind your iptables ruleset, it will make your life easier. Draw a flow chart if you must.</p>
<p style="margin-bottom:0;padding-bottom:0;"><strong>Tip 7: Understand the way that iptables processes rules.</strong></p>
<p style="margin-top:0;padding-top:0;">Remember, the rules start at the top of the chain and go down, unless specified otherwise. Crack open the <a href="http://linux.die.net/man/8/iptables">iptables man page</a> and learn about the options you are using.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2012/iptables-tips-and-tricks-not-locking-yourself-out/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iptables Tips and Tricks – Troubleshooting Rulesets</title>
		<link>http://blog.softlayer.com/2012/iptables-tips-and-tricks-%e2%80%93-troubleshooting-rulesets/</link>
		<comments>http://blog.softlayer.com/2012/iptables-tips-and-tricks-%e2%80%93-troubleshooting-rulesets/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 17:34:58 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[chain]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[packets]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6831</guid>
		<description><![CDATA[One of the most time consuming tasks with iptables is troubleshooting a problematic ruleset. That will not change no matter how much experience you have with it. However, with the right mindset, this task becomes considerably easier. If you missed my last installment about iptables rule processing, here&#8217;s a crash course: The rules start at [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most time consuming tasks with iptables is troubleshooting a problematic ruleset. That will not change no matter how much experience you have with it. However, with the right mindset, this task becomes considerably easier.</p>
<p style="margin-bottom:0; padding-bottom:0;">If you missed my last installment about <a href="http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/">iptables rule processing</a>, here&#8217;s a crash course:</p>
<ol style="margin-top:0; padding-top:0;">
<li>The rules start at the top, and proceed down, one by one unless otherwise directed.</li>
<li>A rule must match exactly.</li>
<li>Once iptables has accepted, rejected, or dropped a packet, it will not process any further rules on it.</li>
</ol>
<p>There are essentially two things that you will be troubleshooting with iptables &#8230; Either <strong>it&#8217;s not accepting traffic and it should be</strong> OR <strong>it&#8217;s accepting traffic and it shouldn&#8217;t be</strong>. If the server is intermittently blocking or accepting traffic, that may take some additional troubleshooting, and it may not even be related to iptables.</p>
<p>Keep in mind what you are looking for, and don&#8217;t jump to any conclusions. Troubleshooting iptables takes patience and time, and there shouldn&#8217;t be any guesswork involved. If you have a configuration of 800 rules, you should expect to need to look through every single rule until you find the rule that is causing your problems. </p>
<p style="margin-bottom:0; padding-bottom:0;">Before you begin troubleshooting, you first need to know some information about the traffic:</p>
<ol style="margin-top:0; padding-top:0;">
<li>What is the source IP address or range that is having difficulty connecting?</li>
<li>What is the destination IP address or website IP?</li>
<li>What is the port or port range affected, or what type of traffic is it (TCP, ICMP, etc.)?</li>
<li>Is it supposed to be accepted or blocked?</li>
</ol>
<p>Those bits of information should be all you need to begin troubleshooting a buggy ruleset, except in some rare cases that are outside the scope of this article.</p>
<p style="margin-bottom:0; padding-bottom:0;">Here are some things to keep in mind (especially if you did not program every rule by hand):</p>
<ul>
<li>iptables has three built in chains. These are for <code>INPUT</code> &ndash; the traffic coming in to the server, <code>OUTPUT</code> &ndash; the traffic coming out of the server, and <code>FORWARD</code> &ndash; traffic that is not destined to or coming from the server (usually only used when iptable is acting as a firewall for other servers). You will start your troubleshooting at the top of one of these three chains, depending on the type of traffic.</li>
<li>The &#8220;<code>target</code>&#8221; is the action that is taken when the rule matches. This may be another custom chain, so if you see a rule with another chain as the <code>target</code> that matches exactly, be sure to step through every rule in that chain as well. In the following example, you will see the <code>BLACKLIST2</code> sub-chain that applies to traffic on port 80. If traffic comes through on port 80, it will be diverted to this other chain.</li>
<li>The <code>RETURN</code> target indicates that you should return to the parent chain. If you see a rule that matches with a <code>RETURN</code> target, stop all your troubleshooting on the current chain, and return the rule directly after the rule that referenced the custom chain.</li>
<li>If there are no matching rules, the chain policy is applied.</li>
<li>There may be rules in the &#8220;<code>nat</code>,&#8221; &#8220;<code>mangle</code>&#8221; or &#8220;<code>raw</code>&#8221; tables that are blocking or diverting your traffic. Typically, all the rules will be in the &#8220;<code>filter</code>&#8221; table, but you might run into situations where this is not the case. Try running this to check: <code>iptables -t mangle -nL ; iptables -t nat -nL ; iptables -t raw -nL</code></li>
<li>Be cognisant of the policy. If the policy is <code>ACCEPT</code>, all traffic that does not match a rule will be accepted. Conversely, if the policy is <code>DROP</code> or <code>REJECT</code>, all traffic that does not match a rule will be blocked.</li>
<li>My goal with this article is to introduce you to the algorithm by which you can troubleshoot a more complex ruleset. It is intentionally left simple, but you should still follow through even when the answer may be obvious.</li>
</ul>
<p>Here is an example ruleset that I will be using for an example:</p>
<p><code>Chain INPUT (policy DROP)<br />
target     prot opt source               destination<br />
BLACKLIST2 tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:50<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:53<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:22<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:1010</p>
<p>Chain BLACKLIST2 (1 references)<br />
target     prot opt source               destination<br />
REJECT     *    --  123.123.123.123      0.0.0.0/0<br />
REJECT     *    --  45.34.234.234        0.0.0.0/0<br />
ACCEPT     *    --  0.0.0.0/0            0.0.0.0/0</code></p>
<p>Here is the problem: Your server is accepting SSH traffic to anyone, and you wish to only allow SSH to your IP &ndash; 111.111.111.111. We know that this is inbound traffic, so this will affect the <code>INPUT</code> chain.</p>
<p style="margin-bottom:0; padding-bottom:0;">We are looking for:</p>
<div style="margin-left: 20px; margin-top:0; padding-top:0;">source IP: any<br />
destination IP: any<br />
protocol: tcp<br />
port: 22</div>
<p><strong>Step 1:</strong> The first rule denotes any source IP and and destination IP on destination port 80. Since this is regarding port 22, this rule does not match, so we&#8217;ll continue to the next rule. If the traffic here was on port 80, it would invoke the <code>BLACKLIST2</code> sub chain.<br />
<strong>Step 2:</strong> The second rule denotes any source IP and any destination IP on destination port 50. Since this is regarding port 22, this rule does not match, so let&#8217;s continue on.<br />
<strong>Step 3:</strong> The third rule denotes any source IP and any destination IP on destination port 53. Since this is regarding port 22, this rule does not match, so let&#8217;s continue on.<br />
<strong>Step 4:</strong> The fourth rule denotes any source IP and any destination IP on destination port 22. Since this is regarding port 22, this rule matches exactly. The target <code>ACCEPT</code> is applied to the traffic. We found the problem, and now we need to construct a solution. I will be showing you the Redhat method of doing this.</p>
<p>Do this to save the running ruleset as a file:</p>
<p><code>iptables-save > current-iptables-rules</code></p>
<p>Then edit the <code>current-iptables-rules</code> file in your favorite editor, and find the rule that looks like this:</p>
<p><code>-A INPUT -p tcp --dport 22 -j ACCEPT</code></p>
<p>Then you can modify this to only apply to your IP address (the source, or &#8220;<code>-s</code>&#8220;, IP address).</p>
<p><code>-A INPUT -p tcp -s 111.111.111.111 --dport 22 -j ACCEPT</code></p>
<p>Once you have this line, you will need to load the iptables configuration from this file for testing. </p>
<p><code>iptables-restore &lt; current-iptables-rules</code></p>
<p>Don&#8217;t directly edit the <code>/etc/sysconfig/iptables</code> file as this might lock you out of your server. It is good practice to test a configuration before saving to the system configuration files. This way, if you do get locked out, you can reboot your server and it will be working. The ruleset should look like this now:</p>
<p><code>Chain INPUT (policy DROP)<br />
target     prot opt source               destination<br />
BLACKLIST2 tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:50<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:53<br />
ACCEPT     tcp  --  111.111.111.111      0.0.0.0/0           tcp dpt:22<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:1010</p>
<p>Chain BLACKLIST2 (1 references)<br />
target     prot opt source               destination<br />
REJECT     *    --  123.123.123.123      0.0.0.0/0<br />
REJECT     *    --  45.34.234.234        0.0.0.0/0<br />
ACCEPT     *    --  0.0.0.0/0            0.0.0.0/0</code></p>
<p>The policy of &#8220;<code>DROP</code>&#8221; will now block any other connection on port 22. Remember, the rule must match exactly, so the rule on port 22 now *ONLY* applies if the IP address is 111.111.111.111.</p>
<p>Once you have confirmed that the rule is behaving properly (be sure to test from another IP address to confirm that you are not able to connect), you can write the system configuration:</p>
<p><code>service iptables save</code></p>
<p>If this troubleshooting sounds boring and repetitive, you are right. However, this is the secret to solid iptables troubleshooting. As I said earlier, there is no guesswork involved. Just take it step by step, make sure the rule matches exactly, and follow it through till you find the rule that is causing the problem. This method may not be fast, but it&#8217;s reliable. You&#8217;ll look like an expert in no time.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2012/iptables-tips-and-tricks-%e2%80%93-troubleshooting-rulesets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iptables Tips and Tricks &#8211; Rule Processing</title>
		<link>http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/</link>
		<comments>http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 17:40:33 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[chain]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[packets]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[traffic]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6802</guid>
		<description><![CDATA[As I mentioned in &#8220;iptables Tips and Tricks &#8211; Port Redirection,&#8221; iptables is probably a complete mystery to a lot of users, and one the biggest hurdles is understanding the method by which it filters traffic &#8230; Once you understand this, you&#8217;ll be able to tame the beast. When I think of iptables, the best [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in &#8220;<a href="http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/">iptables Tips and Tricks &#8211; Port Redirection</a>,&#8221; iptables is probably a complete mystery to a lot of users, and one the biggest hurdles is understanding the method by which it filters traffic &#8230; Once you understand this, you&#8217;ll be able to tame the beast.</p>
<p>When I think of <a href="http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/">iptables</a>, the best analogy that comes to mind is a gravity coin sorting bank with four rules and one policy. If you&#8217;re not familiar with a gravity coin sorting bank, each coin is starts at the same place and slides down an declined plane until it can fall into it&#8217;s appropriate tube:</p>
<p><img class="centered" src="http://cdn.softlayer.com/innerlayer/rulesorter.png" alt="iptables Rule Sorter"/></p>
<p>As you can see, once a coin starts down the path, there are four rules &ndash; each one &#8220;filtering traffic&#8221; based on the width of the coin in millimeters (Quarter = 25mm, Nickel = 22mm, Penny = 20mm, Dime = 18mm). Due to possible inconsistencies in the coins, the tube widths are slightly larger than <a href="http://en.wikipedia.org/wiki/Coins_of_the_United_States_dollar">the official sizes of each coin</a> to prevent jamming. At the end of the line, if a coin didn&#8217;t fit in any of the tubes, it&#8217;s dropped out of the sorter.</p>
<p>As we use this visualization to apply to iptables, there are three important things to remember:</p>
<ol>
<li>The rules start at the top, and proceed down, one by one unless otherwise directed.</li>
<li>A rule must match exactly.</li>
<li>Once iptables has accepted, rejected, or dropped a packet, it will not process any further rules on it.</li>
</ol>
<p>Let&#8217;s jump back to the coin sorter. What would happen if you introduced a 23mm coin (slightly larger than a nickel)? What would happen if you introduced a 17mm coin (smaller than a dime)? What would happen if you dropped in a $1 coin @ 26.5mm?</p>
<p>In the first scenario, the coin would enter into the rule processing by being dropped in at the top. It would first pass by the dime slot, which requires a diameter of less than 18mm. It passes by the pennies slot as well, which requires less than 20mm. It continues past the nickels slot, which requires 22mm or less. It will then be &#8220;accepted&#8221; into the quarters slot, and there will be no further &#8220;processing&#8221; on the coin.</p>
<p>The iptables rules might look something like this:</p>
<p><code>Chain INPUT (policy DROP)<br />
target 	prot opt source           	destination<br />
ACCEPT      all  --- 0.0.0.0/0		0.0.0.0/0	width<18.0mm<br />
ACCEPT      all  --- 0.0.0.0/0		0.0.0.0/0	width<20.0mm<br />
ACCEPT      all  --- 0.0.0.0/0		0.0.0.0/0	width<22.0mm<br />
ACCEPT      all  --- 0.0.0.0/0		0.0.0.0/0	width<25.0mm</code></p>
<p>It's important to remember that once iptables has accepted, rejected, or dropped a packet, it will not process any further rules on it. In the second scenario (17mm coin), the coin would only be processed through the first rule; the other 3 rules would not be used even though the coin would meet their rules as well. Just because a port or and IP address is allowed somewhere in a chain, if a matching rule has dropped the packet, no further rules will be processed.</p>
<p>The final scenario (26.5mm coin) outlines a situation where none of the rules match, and this indicates that the policy will be used. In the coin bank example, it would be physically dropped off the side of the bank. iptables keeps a tally of the number of packets dropped and the corresponding size of the data. You can view this data by using the "<code>iptables -vnL</code>" command.</p>
<p><code>Chain OUTPUT (policy ACCEPT 3418K packets, 380M bytes)</code></p>
<p>cPanel even uses this tally functionality to track bandwidth usage (You may have seen the "<code>acctboth</code>" chain - this is used for tracking usage per IP).</p>
<p>So there you have it: iptables is just like a gravity coin sorting bank!</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Pros and Cons of Two-Factor Authentication</title>
		<link>http://blog.softlayer.com/2011/the-pros-and-cons-of-two-factor-authentication/</link>
		<comments>http://blog.softlayer.com/2011/the-pros-and-cons-of-two-factor-authentication/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 16:15:47 +0000</pubDate>
		<dc:creator>Steve Kinman</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Executive Blog]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[certification]]></category>
		<category><![CDATA[compliance]]></category>
		<category><![CDATA[identification]]></category>
		<category><![CDATA[industry]]></category>
		<category><![CDATA[internal]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[physical]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[token]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6779</guid>
		<description><![CDATA[The government (FISMA), banks (PCI) and the healthcare industry are huge proponents of two-factor authentication, a security measure that requires two different kinds of evidence that you are who you say you are &#8230; or that you should have access to what you&#8217;re trying to access. In many cases, it involves using a combination of [...]]]></description>
			<content:encoded><![CDATA[<p>The government (FISMA), banks (PCI) and the healthcare industry are huge proponents of two-factor authentication, a security measure that requires two different kinds of evidence that you are who you say you are &#8230; or that you should have access to what you&#8217;re trying to access. In many cases, it involves using a combination of a physical device and a secure password, so those huge industries were early adopters of the practice. In our definition, two-factor authentication is providing &#8220;something you know, and something you have.&#8221; When you&#8217;re talking about national security, money or people&#8217;s lives, you don&#8217;t want someone with &#8220;password&#8221; as their password to unwittingly share his or her access to reams valuable information. </p>
<p>What is there not to like about two-factor identification?</p>
<p>That question is one of the biggest issues I&#8217;ve run into as we continue pursuing compliance and best practices in security &#8230; We can turn on two-factor authentication everywhere &ndash; the portal, the vpn, the PoPs, internal servers, desktops, wireless devices &ndash; and make the entire SoftLayer IS team hate us, or we can tell all the admins, auditors and security chiefs of the world to harden their infrastructure without it. </p>
<p>Regardless of which direction we go, someone isn&#8217;t going to like me when this decision is made. </p>
<p>There are definite pros and cons of implementing and requiring two-factor authentication everywhere, so I started a running list that I&#8217;ve copied below. At the end of this post, I&#8217;d love for you to <strong>weigh in with your thoughts on this subject</strong>. Any ideas and perspective you can provide as a customer will help us make informed decisions as we move forward.</p>
<p style="margin-bottom:0; padding-bottom:0;"><strong>Pros</strong></p>
<ul style="margin-top:0; padding-top:0;">
<li>It&#8217;s secure. Really secure.</li>
<li>It is a great deterrent. Why even try to hack an account when you know a secondary token is going to be needed (and only good for a few seconds)?</li>
<li>It can keep you or your company from being in the news for all the wrong reasons!</li>
</ul>
<p style="margin-bottom:0; padding-bottom:0;"><strong>Cons</strong></p>
<ul style="margin-top:0; padding-top:0;">
<li>It&#8217;s slow and cumbersome &#8230; Let&#8217;s do some math, 700 employees, 6 logins per day on average means 4200 logins per day. Assume 4 seconds per two-factor login, and you&#8217;re looking at 16,800 extra seconds (4.66 hours) a day shifted from productivity to simply logging into your systems.</li>
<li>Users have to &#8220;have&#8221; their &#8220;something you have&#8221; all the time &#8230; Whether that&#8217;s an iPhone, a keyfob or a credit card-sized token card.</li>
<li>RSA SecureID was <a href="http://money.cnn.com/2011/06/08/technology/securid_hack/index.htm">HACKED</a>! I know of at least one financial firm that had to turn off two-factor authentication after this came up.</li>
<li>People don&#8217;t like the extra typing.</li>
<li>System Administrators hate the overhead on their systems and the extra points of failure.</li>
</ul>
<p>As you can start to see, the volume of cons out weigh out the pros, but the comparison isn&#8217;t necessarily quantitative. If one point is qualitatively more significant than two hundred contrasting points, which do you pay attention to? If you say &#8220;the significant point,&#8221; then the question becomes how we quantify the qualitativeness &#8230; if that makes any sense.</p>
<p>I had been a long-time hater of two-factor authentication because of my history as a Windows sysadmin, but as I&#8217;ve progressed in my career, I hate to admit that I became a solid member of Team Two-Factor and support its merits. I think the qualitative significance of the pros out weigh the quantitative advantage the cons have, so as much as it hurts, I now get to try to sway our senior systems managers to the dark side as well.</p>
<p>If you support my push for further two-factor authentication implementation, wish me luck (&#8217;cause I will need it). If you&#8217;re on Team Anti-Two-Factor, let me know what they key points are when you&#8217;ve decided against it.</p>
<p>-<a href="http://twitter.com/skinman454">@skinman454</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/the-pros-and-cons-of-two-factor-authentication/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Using iPerf to Troubleshoot Speed/Throughput Issues</title>
		<link>http://blog.softlayer.com/2011/using-iperf-to-troubleshoot-speedthroughput-issues/</link>
		<comments>http://blog.softlayer.com/2011/using-iperf-to-troubleshoot-speedthroughput-issues/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 15:45:17 +0000</pubDate>
		<dc:creator>Andrew Tyler</dc:creator>
				<category><![CDATA[Customer Service]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[connection]]></category>
		<category><![CDATA[engineer]]></category>
		<category><![CDATA[iPerf]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[NOC]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[TCP]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[throughput]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6751</guid>
		<description><![CDATA[Two of the most common network characteristics we look at when investigating network-related concerns in the NOC are speed and throughput. You may have experienced the following scenario yourself: You just provisioned a new bad-boy server with a gigabit connection in a data center on the opposite side of the globe. You begin to upload [...]]]></description>
			<content:encoded><![CDATA[<p>Two of the most common network characteristics we look at when investigating network-related concerns in the NOC are speed and throughput. You may have experienced the following scenario yourself: You just provisioned a new bad-boy server with a gigabit connection in a data center on the opposite side of the globe. You begin to upload your data and to your shock, you see &#8220;Time Remaining: 10 Hours.&#8221; &#8220;What&#8217;s wrong with the network?&#8221; you wonder. The traceroute and MTR look fine, but where&#8217;s the performance and bandwidth I&#8217;m paying for? </p>
<p>This issue is all too common and it has nothing to do with the network, but in fact, the culprits are none other than TCP and the laws of physics.</p>
<p>In data transmission, TCP sends a certain amount of data then pauses. To ensure proper delivery of data, it doesn&#8217;t send more until it receives an acknowledgement from the remote host that all data was received. This is called the &#8220;TCP Window.&#8221; Data travels at the speed of light, and typically, most hosts are fairly close together. This &#8220;windowing&#8221; happens so fast we don&#8217;t even notice it. But as the distance between two hosts increases, the speed of light remains constant. Thus, the further away the two hosts, the longer it takes for the sender to receive the acknowledgement from the remote host, reducing overall throughput. This effect is called &#8220;Bandwidth Delay Product,&#8221; or BDP.</p>
<p>We can overcome BDP to some degree by sending more data at a time. We do this by adjusting the &#8220;TCP Window&#8221; &ndash; telling TCP to send more data per flow than the default parameters. Each OS is different and the default values will vary, but most all operating systems allow tweaking of the TCP stack and/or using parallel data streams. So what is iPerf and how does it fit into all of this?</p>
<p style="margin-bottom:0; padding-bottom:0;"><strong>What is iPerf?</strong></p>
<p style="margin-top:0; padding-top:0;"><a href="http://sourceforge.net/projects/iperf/">iPerf</a> is simple, open-source, command-line, network diagnostic tool that can run on Linux, BSD, or Windows platforms which you install on two endpoints. One side runs in a &#8216;server&#8217; mode listening for requests; the other end runs &#8216;client&#8217; mode that sends data. When activated, it tries to send as much data down your pipe as it can, spitting out transfer statistics as it does. What&#8217;s so cool about iPerf is you can test in real time any number of TCP window settings, even using parallel streams. There&#8217;s even a Java based GUI you can install that runs on top of it called, JPerf (JPerf is beyond the scope of this article, but I recommend looking into it). What&#8217;s even cooler is that because iPerf resides in memory, there are no files to clean up.</p>
<p><span id="more-6751"></span></p>
<p style="margin-bottom:0; padding-bottom:0;"><strong>How do I use iPerf?</strong></p>
<p style="margin-top:0; padding-top:0;">iPerf can be quickly downloaded from <a href="http://sourceforge.net/projects/iperf/">SourceForge</a> to be installed. It uses port 5001 by default, and the bandwidth it displays is from the client to the server. Each test runs for 10 seconds by default, but virtually every setting is adjustable. Once installed, simply bring up the command line on both of the hosts and run these commands.</p>
<p>On the server side:<br />
<code>iperf -s</code></p>
<p>On the client side:<br />
<code>iperf -c [server_ip]</code></p>
<p>The output on the client side will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#iperf -c 10.10.10.5</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Client connecting to 10.10.10.5, TCP port <span style="color: #000000;">5001</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">16.0</span> KByte <span style="color: #7a0874; font-weight: bold;">&#40;</span>default<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">local</span> 0.0.0.0 port <span style="color: #000000;">46956</span> connected with 168.192.1.10 port <span style="color: #000000;">5001</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval       Transfer     Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">10.0</span> sec  <span style="color: #000000;">10.0</span> MBytes  <span style="color: #000000;">1.00</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

<p>There are a lot of things we can do to make this output better with more meaningful data. For example, let&#8217;s say we want the test to run for 20 seconds instead of 10 (<code>-t 20</code>), and we want to display transfer data every 2 seconds instead of the default of 10 (<code>-i 2</code>), and we want to test on port 8000 instead of 5001 (<code>-p 8000</code>). For the purposes of this exercise, let&#8217;s use those customization as our baseline. This is what the command string would look like on both ends:</p>
<div style="margin-left:20px;">
<p style="margin-bottom:0;padding-bottom:0;">Client Side:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#iperf -c 10.10.10.5 -p 8000 -t 20 -i 2</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Client connecting to 10.10.10.5, TCP port <span style="color: #000000;">8000</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">16.0</span> KByte <span style="color: #7a0874; font-weight: bold;">&#40;</span>default<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">local</span> 10.10.10.10 port <span style="color: #000000;">46956</span> connected with 10.10.10.5 port <span style="color: #000000;">8000</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval       Transfer     Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">6.00</span> MBytes  <span style="color: #000000;">25.2</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">2.0</span>- <span style="color: #000000;">4.0</span> sec  <span style="color: #000000;">7.12</span> MBytes  <span style="color: #000000;">29.9</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">4.0</span>- <span style="color: #000000;">6.0</span> sec  <span style="color: #000000;">7.00</span> MBytes  <span style="color: #000000;">29.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">6.0</span>- <span style="color: #000000;">8.0</span> sec  <span style="color: #000000;">7.12</span> MBytes  <span style="color: #000000;">29.9</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">8.0</span>-<span style="color: #000000;">10.0</span> sec  <span style="color: #000000;">7.25</span> MBytes  <span style="color: #000000;">30.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">10.0</span>-<span style="color: #000000;">12.0</span> sec  <span style="color: #000000;">7.00</span> MBytes  <span style="color: #000000;">29.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">12.0</span>-<span style="color: #000000;">14.0</span> sec  <span style="color: #000000;">7.12</span> MBytes  <span style="color: #000000;">29.9</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">14.0</span>-<span style="color: #000000;">16.0</span> sec  <span style="color: #000000;">7.25</span> MBytes  <span style="color: #000000;">30.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">16.0</span>-<span style="color: #000000;">18.0</span> sec  <span style="color: #000000;">6.88</span> MBytes  <span style="color: #000000;">28.8</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">7.25</span> MBytes  <span style="color: #000000;">30.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">70.1</span> MBytes  <span style="color: #000000;">29.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

<p style="margin-bottom:0;padding-bottom:0;">Server Side:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#iperf -s -p 8000 -i 2</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Server listening on TCP port <span style="color: #000000;">8000</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">8.00</span> KByte <span style="color: #7a0874; font-weight: bold;">&#40;</span>default<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">852</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">local</span> 10.10.10.5 port <span style="color: #000000;">8000</span> connected with 10.10.10.10 port <span style="color: #000000;">58316</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval Transfer Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">6.05</span> MBytes  <span style="color: #000000;">25.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">2.0</span>- <span style="color: #000000;">4.0</span> sec  <span style="color: #000000;">7.19</span> MBytes  <span style="color: #000000;">30.1</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">4.0</span>- <span style="color: #000000;">6.0</span> sec  <span style="color: #000000;">6.94</span> MBytes  <span style="color: #000000;">29.1</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">6.0</span>- <span style="color: #000000;">8.0</span> sec  <span style="color: #000000;">7.19</span> MBytes  <span style="color: #000000;">30.2</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">8.0</span>-<span style="color: #000000;">10.0</span> sec  <span style="color: #000000;">7.19</span> MBytes  <span style="color: #000000;">30.1</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">10.0</span>-<span style="color: #000000;">12.0</span> sec  <span style="color: #000000;">6.95</span> MBytes  <span style="color: #000000;">29.1</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">12.0</span>-<span style="color: #000000;">14.0</span> sec  <span style="color: #000000;">7.19</span> MBytes  <span style="color: #000000;">30.2</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">14.0</span>-<span style="color: #000000;">16.0</span> sec  <span style="color: #000000;">7.19</span> MBytes  <span style="color: #000000;">30.2</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">16.0</span>-<span style="color: #000000;">18.0</span> sec  <span style="color: #000000;">6.95</span> MBytes  <span style="color: #000000;">29.1</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">7.19</span> MBytes  <span style="color: #000000;">30.1</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">70.1</span> MBytes  <span style="color: #000000;">29.4</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

</div>
<p>There are many, many other parameters you can set that are beyond the scope of this article, but for our purposes, the main use is to prove out our bandwidth. This is where we&#8217;ll use the TCP window options and parallel streams. To set a new TCP window you use the <code>-w</code> switch and you can set the parallel streams by using <code>-P</code>.</p>
<p>Increased TCP window commands:</p>
<p>Server side:<br />
<code>#iperf -s -w 1024k -i 2</code></p>
<p>Client side:<br />
<code>#iperf -i 2 -t 20 -c 10.10.10.5 -w 1024k</code></p>
<p>And here are the iperf results from two Softlayer file servers &ndash; one in Washington, D.C., acting as Client, the other in Seattle acting as Server:</p>
<div style="margin-left:20px;">
<p style="margin-bottom:0;padding-bottom:0;">Client Side:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># iperf -i 2 -t 20 -c 10.10.10.5 -p 8000 -w 1024k</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Client connecting to 10.10.10.5, TCP port <span style="color: #000000;">8000</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">1.00</span> MByte <span style="color: #7a0874; font-weight: bold;">&#40;</span>WARNING: requested <span style="color: #000000;">1.00</span> MByte<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">local</span> 10.10.10.10 port <span style="color: #000000;">53903</span> connected with 10.10.10.5 port <span style="color: #000000;">5001</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval       Transfer     Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">109</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">2.0</span>- <span style="color: #000000;">4.0</span> sec  <span style="color: #000000;">28.5</span> MBytes   <span style="color: #000000;">120</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">4.0</span>- <span style="color: #000000;">6.0</span> sec  <span style="color: #000000;">28.4</span> MBytes   <span style="color: #000000;">119</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">6.0</span>- <span style="color: #000000;">8.0</span> sec  <span style="color: #000000;">28.9</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">8.0</span>-<span style="color: #000000;">10.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">10.0</span>-<span style="color: #000000;">12.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">122</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">12.0</span>-<span style="color: #000000;">14.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">14.0</span>-<span style="color: #000000;">16.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">122</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">16.0</span>-<span style="color: #000000;">18.0</span> sec  <span style="color: #000000;">27.9</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">122</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>-<span style="color: #000000;">20.0</span> sec   <span style="color: #000000;">283</span> MBytes   <span style="color: #000000;">118</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

<p style="margin-bottom:0;padding-bottom:0;">Server Side:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#iperf -s -w 1024k -i 2 -p 8000</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Server listening on TCP port <span style="color: #000000;">8000</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">1.00</span> MByte
<span style="color: #660033;">------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">local</span> 10.10.10.5 port <span style="color: #000000;">8000</span> connected with 10.10.10.10 port <span style="color: #000000;">53903</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval       Transfer     Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">109</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">2.0</span>- <span style="color: #000000;">4.0</span> sec  <span style="color: #000000;">28.6</span> MBytes   <span style="color: #000000;">120</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">4.0</span>- <span style="color: #000000;">6.0</span> sec  <span style="color: #000000;">28.3</span> MBytes   <span style="color: #000000;">119</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">6.0</span>- <span style="color: #000000;">8.0</span> sec  <span style="color: #000000;">28.9</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">8.0</span>-<span style="color: #000000;">10.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">10.0</span>-<span style="color: #000000;">12.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">12.0</span>-<span style="color: #000000;">14.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">14.0</span>-<span style="color: #000000;">16.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">122</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">16.0</span>-<span style="color: #000000;">18.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>-<span style="color: #000000;">20.0</span> sec   <span style="color: #000000;">283</span> MBytes   <span style="color: #000000;">118</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

</div>
<p>We can see here, that by increasing the TCP window from the default value to 1MB (1024k) we achieved around a 400% increase in throughput over our baseline. Unfortunately, this is the limit of this OS in terms of Window size. So what more can we do? Parallel streams! With multiple simultaneous streams we can fill the pipe close to its maximum usable amount.</p>
<p>Parallel Stream Command:<br />
<code>#iperf -i 2 -t 20 -c -p 8000 10.10.10.5 -w 1024k -P 7</code></p>
<div style="margin-left:20px;">
<p style="margin-bottom:0;padding-bottom:0;">Client Side:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#iperf -i 2 -t 20 -c -p 10.10.10.5 -w 1024k -P 7</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Client connecting to 10.10.10.5, TCP port <span style="color: #000000;">8000</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">1.00</span> MByte <span style="color: #7a0874; font-weight: bold;">&#40;</span>WARNING: requested <span style="color: #000000;">1.00</span> MByte<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">------------------------------------------------------------</span>
 <span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval       Transfer     Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">24.9</span> MBytes   <span style="color: #000000;">104</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">24.9</span> MBytes   <span style="color: #000000;">104</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.6</span> MBytes   <span style="color: #000000;">107</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">24.9</span> MBytes   <span style="color: #000000;">104</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.8</span> MBytes   <span style="color: #000000;">108</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">109</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">109</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SUM<span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec   <span style="color: #000000;">178</span> MBytes   <span style="color: #000000;">746</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#40;</span>output omitted <span style="color: #000000; font-weight: bold;">for</span> brevity on server <span style="color: #000000; font-weight: bold;">&amp;</span> client<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.2</span> MBytes   <span style="color: #000000;">118</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.8</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">117</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.9</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.8</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.9</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SUM<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec   <span style="color: #000000;">200</span> MBytes   <span style="color: #000000;">837</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SUM<span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">1.93</span> GBytes   <span style="color: #000000;">826</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

<p style="margin-bottom:0;padding-bottom:0;">Server Side:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#iperf -s -w 1024k -i 2 -p 8000</span>
<span style="color: #660033;">------------------------------------------------------------</span>
Server listening on TCP port <span style="color: #000000;">8000</span>
TCP window <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">1.00</span> MByte
<span style="color: #660033;">------------------------------------------------------------</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">local</span> 10.10.10.10 port <span style="color: #000000;">8000</span> connected with 10.10.10.5 port <span style="color: #000000;">53903</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> ID<span style="color: #7a0874; font-weight: bold;">&#93;</span> Interval       Transfer     Bandwidth
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.7</span> MBytes   <span style="color: #000000;">108</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">24.9</span> MBytes   <span style="color: #000000;">104</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">24.9</span> MBytes   <span style="color: #000000;">104</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">24.9</span> MBytes   <span style="color: #000000;">104</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">10</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">108</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">109</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec  <span style="color: #000000;">25.9</span> MBytes   <span style="color: #000000;">109</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SUM<span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>- <span style="color: #000000;">2.0</span> sec   <span style="color: #000000;">178</span> MBytes   <span style="color: #000000;">747</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.8</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.3</span> MBytes   <span style="color: #000000;">119</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.8</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">10</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.1</span> MBytes   <span style="color: #000000;">118</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.0</span> MBytes   <span style="color: #000000;">118</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">28.8</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>  <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec  <span style="color: #000000;">29.0</span> MBytes   <span style="color: #000000;">121</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SUM<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000;">18.0</span>-<span style="color: #000000;">20.0</span> sec   <span style="color: #000000;">200</span> MBytes   <span style="color: #000000;">838</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec
<span style="color: #7a0874; font-weight: bold;">&#91;</span>SUM<span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000;">0.0</span>-<span style="color: #000000;">20.1</span> sec  <span style="color: #000000;">1.93</span> GBytes   <span style="color: #000000;">825</span> Mbits<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

</div>
<p>As you can see from the tests above, we were able to increase throughput from 29MB/s with a single stream and the default TCP Window to 824MB/s using a higher window and parallel streams. On a Gigabit link, this about the maximum throughput one could hope to achieve before saturating the link and causing packet loss. The bottom line is, I was able to prove out the network and verify bandwidth capacity was not an issue. From that conclusion, I could focus on tweaking TCP to get the most out of my network.</p>
<p>I&#8217;d like to point out that we will never get 100% out of any link. Typically, 90% utilization is about the real world maximum anyone will achieve. If you get any more, you&#8217;ll begin to saturate the link and incur packet loss. I should also point out that Softlayer doesn&#8217;t directly support iPerf, so it&#8217;s up to you install and play around with. It&#8217;s such a versatile and easy to use little piece of software that it&#8217;s become invaluable to me, and I think it will become invaluable to you as well!</p>
<p>-Andrew</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/using-iperf-to-troubleshoot-speedthroughput-issues/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>iptables Tips and Tricks &#8211; Port Redirection</title>
		<link>http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/</link>
		<comments>http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/#comments</comments>
		<pubDate>Mon, 26 Dec 2011 18:10:16 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[management]]></category>
		<category><![CDATA[ports]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[traffic]]></category>
		<category><![CDATA[walkthrough]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6733</guid>
		<description><![CDATA[One of the most challenging and rewarding aspects of Linux administration is the iptables firewall. To the unenlightened, this can be a confusing black box that breaks your web server and blocks your favorite visitors from viewing your content at the most inconvenient times. This blog is the first in a series aimed at clarifying [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most challenging and rewarding aspects of Linux administration is the <a href="http://www.netfilter.org/projects/iptables/index.html">iptables</a> firewall. To the unenlightened, this can be a confusing black box that breaks your web server and blocks your favorite visitors from viewing your content at the most inconvenient times. This blog is the first in a series aimed at clarifying this otherwise mysterious force at work in your server.</p>
<p>Nothing compares with the frustration of trying to make a program listen on a different port &ndash; like if you wanted to configure your mail client to listen on port 2525. Many times, configuring a program the hard way (some would say the &#8220;correct&#8221; way) using configuration files may not be worth your time and effort &#8230; Especially if the server is running on a control panel that does not natively support this functionality.</p>
<p>Fortunately, iptables offers an elegant solution:</p>
<p><code>iptables -t nat -A PREROUTING -p tcp --dport 2525 -j REDIRECT --to-ports 25</code></p>
<p>What this does:</p>
<ol>
<li>This specifies <code>-t nat</code> to indicate the nat table. Typically rules are added to the &#8220;filter&#8221; table (if you do not specify another table), and this is where the majority of the traffic is handled. In this case, however, we require the use of the nat table.</li>
<li>This rules appends (<code>-A</code>), which means to add the rule at the bottom of the list.
<li>This rule is added to the <code>PREROUTING</code> chain.</li>
<li>For the tcp protocol (<code>-p tcp</code>)</li>
<li>The destination port (<code>--dport</code>) is <code>2525</code> &#8211; this is the port that the client is trying to access on your server.</li>
<li>The traffic is jumped (<code>-j</code>) to the <code>REDIRECT</code> action. This is the action that is taken when the rule matches.</li>
<li>The port is redirected to port <code>25</code> on the server.</li>
</ol>
<p>As you can see, by changing the protocol to either <code>tcp</code> or <code>udp</code> or by adjusting the <code>dport</code> number and the <code>to-ports</code> number, you can redirect any port incoming to any listening port on the server. Just remember that the <code>dport</code> is the port the client machine is trying to connect to (the port they configure in the mail client, for example).</p>
<p>But check this out: Say for example you have a website (shocking, I know). You don&#8217;t have a load balancer or a firewall set up, but you want to split off your email traffic to a second server to reduce strain on your web server. Essentially, you want to take incoming port 25 and redirect it &#8230; to ANOTHER SERVER. With iptables, you can make this work:</p>
<p><code>iptables -t nat -A PREROUTING -p tcp -d 123.123.123.123 --dport 25 -j DNAT --to-destination 10.10.10.10:25</code></p>
<p>What this does:</p>
<ol>
<li>It specifies a destination (<code>-d</code>) IP address. This is not needed, but if you want to limit the email redirection to a single address, this is how you can do it.</li>
<li>It is jumped to <code>DNAT</code>, which stands for destination nat.</li>
<li>The destination and port are specified as arguments on <code>to-destination</code></li>
</ol>
<p>As you can see, this forwards all traffic on port 25 to an internal IP address.</p>
<p>Now, say you want to redirect from a different incoming port to a port on another server:</p>
<p><code>iptables -t nat -A PREROUTING -p tcp --dport 5001 -j DNAT --to-destination 10.10.10.10:25<br />
iptables -t nat -A POSTROUTING -p tcp --dport 25 -j MASQUERADE</code></p>
<p>In this example, the incoming port is different, so we need to change it back to the standard port on the way back out through the primary server.</p>
<p>If you would like further reading on this topic, I recommend this great tutorial:<br />
<a href="http://www.karlrupp.net/en/computer/nat_tutorial">http://www.karlrupp.net/en/computer/nat_tutorial</a></p>
<p>Remember, when you are modifying your running configuration of iptables, you will still need to save your changes in order for it to persist on reboot. Be sure to test your configuration before saving it with &#8220;<code>service iptables save</code>&#8221; so that you don&#8217;t lock yourself out.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/iptables-tips-and-tricks-port-redirection/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>UNIX Sysadmin Boot Camp: bash &#8211; Keyboard Shortcuts</title>
		<link>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash-keyboard-shortcuts/</link>
		<comments>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash-keyboard-shortcuts/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 15:50:17 +0000</pubDate>
		<dc:creator>Ryan Robson</dc:creator>
				<category><![CDATA[Customer Service]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[boot camp]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[excute]]></category>
		<category><![CDATA[keyboard shortcut]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shortcut]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=6476</guid>
		<description><![CDATA[On the support team, we&#8217;re jumping in and out of shells constantly. At any time during my work day, I&#8217;ll see at least four instances of PuTTY in my task bar, so one thing I learned quickly was that efficiency and accuracy in accessing ultimately make life easier for our customers and for us as [...]]]></description>
			<content:encoded><![CDATA[<p>On the support team, we&#8217;re jumping in and out of shells constantly. At any time during my work day, I&#8217;ll see at least four instances of <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">PuTTY</a> in my task bar, so one thing I learned quickly was that efficiency and accuracy in accessing ultimately make life easier for our customers and for us as well. Spending too much time rewriting paths, commands, VI navigation, and history cycling can really bring you to a crawl. So now that you have had some time to study <a href="http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash/">bash</a> and practice a little, I thought I&#8217;d share some of the keyboard shortcuts that help us work as effectively and as expediently as we do. I won&#8217;t be able to cover <em>all</em> of the shortcuts, but these are the ones I use most:</p>
<h3>Tab</h3>
<p style="margin-top:0; padding-top: 0;">[Tab] is one of the first keyboard shortcuts that most people learn, and it&#8217;s ever-so-convenient. Let&#8217;s say you just downloaded <code>pckg54andahalf-5.2.17-v54-2-x86-686-Debian.tar.gz</code>, but a quick listing of the directory shows you ALSO downloaded <code>5.1.11</code>, <code>4.8.6</code> and <code>1.2.3</code> at some point in the past. What was that file name again? Fret not. You know you downloaded 5.2.<em>something</em>, so you just start with, say, <code>pckg</code>, and hit [Tab]. This autocompletes everything that it can match to a unique file name, so if there are no other files that start with &#8220;<code>pckg</code>,&#8221; it will populate the whole file name (and this can occur at any point in a command).</p>
<p>In this case, we&#8217;ve got <em>four</em> different files that are similar:<br />
<code style="background-color:yellow;">pckg54andahalf-5.2.17-v54-2-x86-686-Debian.tar.gz</code> <-- we want this one<br />
<code style="background-color:gray;">pckg54andahalf-5.1.11-v54-2-x86-686-Debian.tar.gz</code><br />
<code style="background-color:gray;">pckg54andahalf-4.8.6-v54-2-x86-686-Debian.tar.gz</code><br />
<code style="background-color:gray;">pckg54andahalf-1.2.3-v54-2-x86-686-Debian.tar.gz</code></p>
<p>So typing "<code>pckg</code>" and hitting [Tab] brings up:<br />
<code>pckg54andahalf-</code></p>
<p><em>NOW</em>, what you could do, knowing what files are there already, is type "<code>5.2</code>" and hit [Tab] again to fill out the rest. However, if you <em>didn't</em> know what the potential matches were, you could <strong>double-tap [Tab]</strong>. This displays all matching file names with that string.</p>
<p>Another fun fact: This trick also works in Windows. <img src='http://blog.softlayer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>CTRL+R</h3>
<p style="margin-top:0; padding-top: 0;">[CTRL+R] is a very underrated shortcut in my humble opinion. When you've been working in the shell for untold hours parsing logs, moving files and editing configs, your bash history can get pretty immense. Often you'll come across a situation where you want to reproduce a command or series of commands that were run regarding a specific file or circumstance. You <em>could</em> type "<code>history</code>" and pore through the commands line by line, but I propose something more efficient: a reverse search.</p>
<p>Example: I've just hopped on my system and discovered that my SVN server isn't doing what it's supposed to. I want to take a look at any SVN related commands that were executed from bash, so I can make sure there were no errors. I'd simply hit [CTRL+R], which would pull up the following prompt:</p>
<p><code>(reverse-i-search)`':</code></p>
<p>Typing "<code>s</code>" at this point would immediately return the first command with the letter "<code>s</code>" in it in the history ... Keep in mind that's not just <em>starting</em> with s, it's <em>containing</em> an s. Finishing that out to "<code>svn</code>" brings up any command executed with those letters in that order. Pressing [CTRL+R] again at this point will cycle through the commands one by one.</p>
<p>In the search, I find the command that was run incorrectly ... There was a typo in it. I can edit the command <em>within</em> the search prompt before hitting enter and committing it to the command prompt. Pretty handy, right? This can quickly become one of your most used shortcuts.</p>
<h3>CTRL+W &#038; CTRL+Y</h3>
<p style="margin-top:0; padding-top: 0;">This pair of shortcuts is the one I find myself using the most. [CTRL+W] will basically take the word before your cursor and "cut" it, just like you would with [CTRL+X] in Windows if you highlighted a word. A "word" doesn't really describe what it cuts in bash, though ... It uses whitespace as a delimiter, so if you have an ultra long file path that you'll probably be using multiple times down the road, you can [CTRL+W] that sucker and keep it stowed away.</p>
<p>Example: I'm typing <code>nano /etc/httpd/conf/httpd.conf</code> (Related: The redundancy of this path always irked me just a little).<br />
Before hitting [ENTER] I tap [CTRL+W], which chops that path right back out and stores it to memory. Because I want to run that command right now as well, I hit [CTRL+Y] to <em>paste</em> it back into the line. When I'm done with that and I'm out referencing other logs or doing work on other files and need to come back to it, I can simply type "<code>nano </code>" and hit [CTRL+Y] to go right back into that file.</p>
<h3>CTRL+C</h3>
<p style="margin-top:0; padding-top: 0;">For the sake of covering most of my bases, I want to make sure that [CTRL+C] is covered. Not only is it useful, but it's absolutely essential for standard shell usage. This little shortcut performs the most invaluable act of killing whatever process you were running at that point. This can go for most anything, aside from the programs that have their own interfaces and kill commands (vi, nano, etc). If you start something, there's a pretty good chance you're going to want to stop it eventually.</p>
<p>I should be clear that this will terminate a process unless that process is otherwise instructed to trap [CTRL+C] and perform a different function. If you're compiling something or running a database command, generally you won't want to use this shortcut unless you know what you're doing. But, when it comes to everyday usage such as running a "<code>top</code>" and then quitting, it's essential.</p>
<h3>Repeating a Command</h3>
<p style="margin-top:0; padding-top: 0;">There are four simple ways you can easily repeat a command with a keyboard shortcut, so I thought I'd run through them here before wrapping up:</p>
<ol>
<li>The [UP] arrow will display the previously executed command.</li>
<li>[CTRL+P] will do the exact same thing as the [UP] arrow.</li>
<li>Typing "<code>!!</code>" and hitting [Enter] will execute the previous command. <em>Note that this actually runs it. The previous two options only display the command, giving you the option to hit [ENTER].</em></li>
<li>Typing "<code>!-1</code>" will do the same thing as "<code>!!</code>", though I want to point out how it does this: When you type "<code>history</code>", you see a numbered list of commands executed in the past <code>-1</code> being the most recent. What "<code>!-1</code>" does is instructs the shell to execute (<code>!</code>) the first item on the history (<code>-1</code>). This same concept can be applied for any command in the history at all ... This can be useful for scripting.</li>
</ol>
<h3>Start Practicing</h3>
<p style="margin-top:0; padding-top: 0;">What it really comes down to is finding what works for you and what suits your work style. There are a number of other shortcuts that are definitely worthwhile to take a look at. There are plenty of cheat sheets on the internet available to print out while you're learning, and I'd highly recommend checking them out. Trust me on this: You'll never regret honing your mastery of bash shortcuts, particularly once you've seen the lightning speed at which you start flying through the command line. The tedium goes away, and the shell becomes a much more friendly, dare I say <em>inviting</em>, place to be.</p>
<p style="margin-bottom:0; padding-bottom:0;"><strong>Quick reference for these shortcuts:</strong></p>
<ul style="margin-top:0; padding-top:0;">
<li><strong>[TAB]</strong> - Autocomplete to furthest point in a unique matching file name or path.</li>
<li><strong>[CTRL+R]</strong> - Reverse search through your bash history</li>
<li><strong>[CTRL+W]</strong> - Cut one "word" back, or until whitespace encountered.</li>
<li><strong>[CTRL+Y]</strong> - Paste a previously cut string</li>
<li><strong>[CTRL+P]</strong> - Display previously run command</li>
<li><strong>[UP]</strong> - Display previously run command</li>
</ul>
<p>-Ryan</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2011/unix-sysadmin-boot-camp-bash-keyboard-shortcuts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
