<?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; Mark Ridlen</title>
	<atom:link href="http://blog.softlayer.com/author/mridlen/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, 15 May 2013 15:33: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 &#8211; Track Bandwidth with iptables</title>
		<link>http://blog.softlayer.com/2013/iptables-tips-and-tricks-track-bandwidth-with-iptables/</link>
		<comments>http://blog.softlayer.com/2013/iptables-tips-and-tricks-track-bandwidth-with-iptables/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 21:30:29 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[bandwidth]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[cPanel]]></category>
		<category><![CDATA[CSF]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[tips and tricks]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=11025</guid>
		<description><![CDATA[As I mentioned in my last post about CSF configuration in iptables, I&#8217;m working on a follow-up post about integrating CSF into cPanel, but I thought I&#8217;d inject a simple iptables use-case for bandwidth tracking. You probably think about iptables in terms of firewalls and security, but it also includes a great diagnostic tool for [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my last post about <a href="http://blog.softlayer.com/2013/iptables-tips-and-tricks-csf-configuration/">CSF configuration in iptables</a>, I&#8217;m working on a follow-up post about integrating CSF into cPanel, but I thought I&#8217;d inject a simple iptables use-case for bandwidth tracking. You probably think about iptables in terms of firewalls and security, but it also includes a great diagnostic tool for counting bandwidth for individual rules or set of rules. If you can block it, you can track it! </p>
<p>The best part about using iptables to track bandwidth is that the tracking is enabled by default. To see this feature in action, add the &#8220;-v&#8221; into the command:</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>$ iptables <span style="color: #660033;">-vnL</span>
Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">2495</span> packets, 104K bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>The output includes counters for both the policies and the rules. To track the rules, you can create a new chain for <code>tracking</code> bandwidth:</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>$ iptables <span style="color: #660033;">-N</span> tracking
<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>$ iptables <span style="color: #660033;">-vnL</span>
...
Chain tracking <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span> references<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination</pre></div></div>

<p>Then you need to set up new rules to match the traffic that you wish to track. In this scenario, let&#8217;s look at inbound http traffic on port 80:</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>$ iptables <span style="color: #660033;">-I</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> tracking
<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>$ iptables <span style="color: #660033;">-vnL</span>
Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">35111</span> packets, 1490K bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
    <span style="color: #000000;">0</span> 	  <span style="color: #000000;">0</span> tracking    tcp  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>       	tcp dpt:<span style="color: #000000;">80</span></pre></div></div>

<p>Now let&#8217;s generate some traffic and check it again:</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>$ iptables <span style="color: #660033;">-vnL</span>
Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">35216</span> packets, 1500K bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
  <span style="color: #000000;">101</span>  <span style="color: #000000;">9013</span> tracking    tcp  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>       	tcp dpt:<span style="color: #000000;">80</span></pre></div></div>

<p>You can see the packet and byte transfer amounts to track the INPUT &mdash; traffic to a <strong>destination</strong> port on your server. If you want track the amount of data that the server is generating, you&#8217;d look for OUTPUT from the <strong>source</strong> port on your server:</p>
<p><span id="more-11025"></span></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>$ iptables <span style="color: #660033;">-I</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> tracking
<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>$ iptables <span style="color: #660033;">-vnL</span>
...
Chain OUTPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">26149</span> packets, 174M bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
  <span style="color: #000000;">488</span> 3367K tracking    tcp  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>       	tcp spt:<span style="color: #000000;">80</span></pre></div></div>

<p>Now that we know how the tracking chain works, we can add in a few different layers to get even more information. That way you can keep your INPUT and OUTPUT chains looking clean.</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>$ iptables –N tracking
<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>$ iptables –N tracking2
<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>$ iptables –I INPUT –j tracking
<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>$ iptables –I OUTPUT –j tracking
<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>$ iptables –A tracking –p tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> –j tracking2
<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>$ iptables –A tracking –p tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">80</span> –j tracking2
<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>$ iptables <span style="color: #660033;">-vnL</span>
&nbsp;
Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">96265</span> packets, 4131K bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
 <span style="color: #000000;">4002</span>  184K tracking    all  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>
&nbsp;
Chain FORWARD <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">0</span> packets, <span style="color: #000000;">0</span> bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
&nbsp;
Chain OUTPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT <span style="color: #000000;">33751</span> packets, 231M bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
 <span style="color: #000000;">1399</span> 9068K tracking    all  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>
&nbsp;
Chain tracking <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span> references<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
 <span style="color: #000000;">1208</span> <span style="color: #000000;">59626</span> tracking2   tcp  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>       	tcp dpt:<span style="color: #000000;">80</span>
  <span style="color: #000000;">224</span> 1643K tracking2   tcp  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>       	tcp spt:<span style="color: #000000;">80</span>
&nbsp;
Chain tracking2 <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span> references<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination</pre></div></div>

<p>Keep in mind that every time a packet passes through one of your rules, it will eat CPU cycles. Diverting all your traffic through 100 rules that track bandwidth may not be the best idea, so it&#8217;s important to have an efficient ruleset. If your server has eight processor cores and tons of overhead available, that concern might be inconsequential, but if you&#8217;re running lean, you could conceivably run into issues. </p>
<p>The easiest way to think about making efficient rulesets is to think about eating the largest slice of pie first. Understand <a href="http://blog.softlayer.com/2012/iptables-tips-and-tricks-rule-processing/">iptables rule processing</a> and put the rules that get more traffic higher in your list. Conversely, save the tiniest pieces of your pie for last. If you run all of your traffic by a rule that only applies to a tiny segment before you screen out larger segments, you&#8217;re wasting processing power.</p>
<p>Another thing to keep in mind is that you do not need to specify a target (in our examples above, we established <code>tracking</code> and <code>tracking2</code> as our targets). If you&#8217;re used to each rule having a specific purpose of either blocking, allowing, or diverting traffic, this simple tidbit might seem revolutionary. For example, we could use this rule:</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>$ iptables <span style="color: #660033;">-A</span> INPUT</pre></div></div>

<p>If that seems a little bare to you, don&#8217;t worry &#8230; It is! The output will show that it is a rule that tracks all traffic in the chain at that point. We&#8217;re appending the data to the end of the chain in this example (&#8220;<code>-A</code>&#8220;) but we could also insert it (&#8220;<code>-I</code>&#8220;) at the top of the chain instead. This command could be helpful if you are using a number of different chains and you want to see the exact volume of packets that are filtered at any given point. Additionally, this strategy could show how much traffic a potential rule would filter before you run it on your production system. Because having several of these kinds of commands can get a little messy, it&#8217;s also helpful to add comments to help sort things out:</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>$ iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-m</span> comment <span style="color: #660033;">--comment</span> <span style="color: #ff0000;">&quot;track all data&quot;</span>
&nbsp;
<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>$ iptables <span style="color: #660033;">-vnL</span>
Chain INPUT <span style="color: #7a0874; font-weight: bold;">&#40;</span>policy ACCEPT 11M packets, 5280M bytes<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 pkts bytes target 	prot opt <span style="color: #000000; font-weight: bold;">in</span> 	out 	<span style="color: #7a0874; font-weight: bold;">source</span>           	destination
   <span style="color: #000000;">98</span>  <span style="color: #000000;">9352</span>        	all  <span style="color: #660033;">--</span>  <span style="color: #000000; font-weight: bold;">*</span>  	<span style="color: #000000; font-weight: bold;">*</span>   	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>        	0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>       	<span style="color: #000000; font-weight: bold;">/*</span> track all data <span style="color: #000000; font-weight: bold;">*/</span></pre></div></div>

<p>Nothing terribly complicated about using iptables to count bandwidth, right? If you have iptables rulesets and you want to get a glimpse at how your traffic is being affected, this little trick could be useful. You can rely on the information iptables gives you about your bandwidth usage, and you won&#8217;t be the only one &#8230; cPanel actually uses iptables to track bandwidth.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2013/iptables-tips-and-tricks-track-bandwidth-with-iptables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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>1</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>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>Sippin Syrup</title>
		<link>http://blog.softlayer.com/2010/sippin-syrup/</link>
		<comments>http://blog.softlayer.com/2010/sippin-syrup/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 14:30:35 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[caffeine]]></category>
		<category><![CDATA[food]]></category>
		<category><![CDATA[overnight]]></category>
		<category><![CDATA[relaxation]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=1654</guid>
		<description><![CDATA[Here on the SoftLayer overnight shift (aka &#8220;team undead&#8221;), the technicians (aka &#8220;SLombies&#8221;) often find it difficult to get a full 8 hours of sleep. Quick science lesson: the body produces melatonin when it is dark outside. This regulates the sleep cycle. So it&#8217;s only natural that it is hard to sleep during the day. [...]]]></description>
			<content:encoded><![CDATA[<p>Here on the SoftLayer overnight shift (aka &#8220;team undead&#8221;), the technicians (aka &#8220;SLombies&#8221;) often find it difficult to get a full 8 hours of sleep.<br />
Quick science lesson: the body produces melatonin when it is dark outside. This regulates the sleep cycle. So it&#8217;s only natural that it is hard to sleep during the day.</p>
<p>Initially I had been drinking a beer or five to go to bed every morning. Since I don&#8217;t want to have liver failure at age 43, I decided to check out some alternatives. I used Unisom Sleep Tabs for a while, but I have been looking for substitutes, since they are essentially the sleep inducing antihistamine contained in NyQuil. The warning on the box says not to consume any alcoholic beverage with these, and it doesn&#8217;t recommend long term usage of the drug.</p>
<p><strong>The new alternative: relaxation beverages</strong><br />
A relaxation beverage is the polar opposite of an energy drink. It is designed to calm and slow you down. They have ingredients such as: kava kava, valerian root, and melatonin. I have tried two different brands: Drank and Sippin Syrup. These are both references to the &#8220;purple stuff&#8221; drug that is created by mixing codeine and sprite. There is also a Purple Stuff brand (codeine free, of course), but I have not had an opportunity to try this yet. You can get it on Amazon: <a href="http://www.amazon.com/16-Pack-Pro-Relaxation-Beverage-Classic/dp/B002SMZM92">http://www.amazon.com/16-Pack-Pro-Relaxation-Beverage-Classic/dp/B002SMZM92</a>.</p>
<p><strong>Drank</strong><br />
You&#8217;ll often find Drank at a 7-11, but sadly the 7-11 near me stopped carrying it. It has a grape soda flavor, and it certainly lacks the medicinal taste of most energy drinks. It is in a standard 16oz energy drink sized can. It will knock you out pretty easily. You can buy it by the case from the website: <a href="http://www.drankbeverage.com/">http://www.drankbeverage.com/</a></p>
<p><strong>Sippin Syrup</strong><br />
This one is my favorite. It&#8217;s effectiveness is very similar to Drank. The best part about this one is that it comes in a resealable container, so you can have just half a dose if you are already tired. It comes in 3 flavors: Purple (grape), Kandy (cream soda), and Griptonite (grape apple flavor). There is also a low carb version called Sippin Syrup Zero, which doesn&#8217;t really interest me personally. They make a concentrated shot version called a Lil Sip. When I ordered, they were nice enough to send me a free T-shirt as well. You can order it by the case (12 or 24 packs) from their website: <a href="http://sippinsyrup.com/">http://sippinsyrup.com/</a></p>
<p>I have been getting much better sleep these days! I highly recommend either of these products.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2010/sippin-syrup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RAS Syndrome</title>
		<link>http://blog.softlayer.com/2010/1638/</link>
		<comments>http://blog.softlayer.com/2010/1638/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 14:27:09 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[acronym]]></category>
		<category><![CDATA[RAS]]></category>
		<category><![CDATA[redundant]]></category>
		<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[syndrome]]></category>
		<category><![CDATA[tech jargon]]></category>

		<guid isPermaLink="false">http://blog.softlayer.com/?p=1638</guid>
		<description><![CDATA[RAS Syndrome. It&#8217;s a condition that plagues not only SoftLayer, but the entire tech industry. Of course, it&#8217;s not even limited to that &#8211; it just happens to hit the tech industry the hardest because of the high amount of acronyms. RAS stands for Redundant Acronym Syndrome, so RAS Syndrome stands for Redundant Acronym Syndrome [...]]]></description>
			<content:encoded><![CDATA[<p>RAS Syndrome. It&#8217;s a condition that plagues not only SoftLayer, but the entire tech industry. Of course, it&#8217;s not even limited to that &#8211; it just happens to hit the tech industry the hardest because of the high amount of acronyms. RAS stands for Redundant Acronym Syndrome, so RAS Syndrome stands for Redundant Acronym Syndrome Syndrome. See the problem here?</p>
<p>Here are some of my favorite examples:</p>
<ul>
<li>ATM Machine</li>
<li>PIN Number</li>
<li>DVD Disc</li>
</ul>
<p>Protocol gets abused a lot:</p>
<ul>
<li>TCP/IP Protocol</li>
<li>HTTP Protocol</li>
<li>FTP Protocol</li>
<li>SIP Protocol</li>
<li>GUI interface</li>
</ul>
<p>And of course the list goes on. Sometimes we can get very redundant. Let&#8217;s start with this example:</p>
<ul>
<li>Battery Backup Unit (BBU)</li>
</ul>
<p>We can make this redundant:</p>
<ul>
<li>BBU Unit</li>
</ul>
<p>Continuing the trend, we can add &#8220;Battery&#8221; to this without sounding too out of place:</p>
<ul>
<li>Battery BBU Unit</li>
</ul>
<p>You need to be careful because you may use a synonym and still be redundant:</p>
<ul>
<li>BBU Module</li>
</ul>
<p>Since &#8220;unit&#8221; and &#8220;module&#8221; refer to basically the same thing, this is also redundant.</p>
<p>I&#8217;m sure this is enough to get you started thinking about it. In time, I&#8217;m sure you&#8217;ll start discovering new redundant RAS acronyms.</p>
<p>-Mark</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2010/1638/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Myths part 2</title>
		<link>http://blog.softlayer.com/2010/security-myths-part-2/</link>
		<comments>http://blog.softlayer.com/2010/security-myths-part-2/#comments</comments>
		<pubDate>Thu, 05 Aug 2010 13:00:42 +0000</pubDate>
		<dc:creator>Mark Ridlen</dc:creator>
				<category><![CDATA[SoftLayer]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[facts]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[myths]]></category>
		<category><![CDATA[operating systems]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SPAM]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://theinnerlayer.softlayer.com/?p=1593</guid>
		<description><![CDATA[Security Myth #4: A hardware firewall will stop the evil hackers from the internet. They also stop viruses and spam emails. The Facts: A hardware firewall will filter your traffic based on a set of rules. If properly configured, this will certainly harden your system from certain types of attacks. However, if you want to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Security Myth #4:</strong> A hardware firewall will stop the evil hackers from the internet. They also stop viruses and spam emails.</p>
<p><strong>The Facts:</strong> A hardware firewall will filter your traffic based on a set of rules. If properly configured, this will certainly harden your system from certain types of attacks. However, if you want to stop intrusion attempts on your server, you probably want to implement brute force protection or intrusion detection (IDS). Most operating systems nowadays include brute force protection in one form or another (although it may not be turned on by default). If you want an IDS, there are several options available. Here at SoftLayer, we offer McAfee Host Intrusion Protection System (or HIPS for short) for Windows systems. This will offer you some additional protection against intrusion attempts, but it is no substitute for a well patched system with strong passwords. This is especially important to know if you contract with an outside agency to configure your firewall for you. It’s easy to delude yourself into a “set it and forget it” attitude toward security. I can’t tell you how many administrators I’ve talked to that have asked “how did I get hacked? I had a firewall!”</p>
<p><strong>The Side Effects:</strong></p>
<ul>
<li>Having a hardware firewall means an additional step to allow access to ports. Can be time consuming.</li>
<li>Having a hardware firewall can potentially mean an additional point of failure.</li>
<li>Too many rules can mean degraded performance.</li>
</ul>
<p><strong>Security Myth #5:</strong> I run a Unix/Linux based system, so I can’t get hacked.</p>
<p><strong>The Facts:</strong> I have seen a fair share of Unix based systems get hacked, simply because the user is unfamiliar with the OS. Running everything from within a control panel is convenient, but make sure you or one of your administrators is familiar with command line access.</p>
<p><strong>The Side Effects:</strong></p>
<ul>
<li>Running a control panel can cause more security holes</li>
</ul>
<p><strong>Security Myth #6:</strong> I have my WordPress (or other web application) patched to the latest version, so I should be fine.</p>
<p><strong>The Facts:</strong> WordPress is a piece of cake to install. You don’t even need to know how to code in HTML. This means you can install it and have it working properly, and still forget to correct your filesystem permissions. You need to make sure that you read the installation documentation and complete all steps. If you just stop reading once the application starts working, you could potentially forget to correct your permissions and someone could gain access as an administrative user. I ran into a situation one time where a user was utilizing a web interface to manage an online marketplace. I was shocked to find out that the link he sent me allowed me in without the use of a password! Make sure that your application doesn’t use the default password or a blank password.</p>
<p><strong>The Side Effects:</strong></p>
<ul>
<li>Having the latest version is great, but make sure you take a 360 degree look around to make sure nothing is out of place</li>
</ul>
<p><strong>Security Myth #7:</strong> I am getting SPAM messages, but I have a firewall.</p>
<p><strong>The Facts:</strong> A firewall does not filter SPAM messages. You might look into the free SpamAssassin software that will filter email for potential SPAM. <a href="http://spamassassin.apache.org/" target="_blank">http://spamassassin.apache.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.softlayer.com/2010/security-myths-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
