<?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>RapidVPS</title>
	<atom:link href="http://blog.rapidvps.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rapidvps.com</link>
	<description>Tips, Tricks and Tutorials for Systems &#38; Network Administrators</description>
	<lastBuildDate>Thu, 22 Sep 2011 01:28:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Optimize your PHP Code with memcached</title>
		<link>http://blog.rapidvps.com/2011/optimize-your-php-code-with-memcached-in-centos/</link>
		<comments>http://blog.rapidvps.com/2011/optimize-your-php-code-with-memcached-in-centos/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 01:10:33 +0000</pubDate>
		<dc:creator>PacketShaper</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux Optimizations]]></category>
		<category><![CDATA[Linux Tools]]></category>
		<category><![CDATA[Optimizations]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://admincheats.com/?p=98</guid>
		<description><![CDATA[So you have written a PHP web application which is being used heavily enough that it needs to be optimized. Good for you! Memcached is just the tool for you. It is very easy to install and use and it will drastically speed up most PHP code that can be optimized with caching. Caching simply [...]]]></description>
			<content:encoded><![CDATA[<p>So you have written a PHP web application which is being used heavily enough that it needs to be optimized. Good for you!<a href="http://admincheats.com/wp-content/uploads/2011/09/memcached-logo-200x152.png"><img class="alignright size-full wp-image-99" title="memcached-logo-200x152" src="http://admincheats.com/wp-content/uploads/2011/09/memcached-logo-200x152.png" alt="PHP Performance Optimization with Memcached" width="200" height="152" /></a></p>
<p>Memcached is just the tool for you. It is very easy to install and use and it will drastically speed up most PHP code that <em>can</em> be optimized with caching.</p>
<p><strong>Caching</strong> simply means taking a piece of data that can be serialized (an SQL query for example) which is resource intensive and does not change <em>extremely</em> often, and storing the resulting data (as opposed to the query) in memory. Any time a matching query is attempted, the result does not need to be fetched from the database and is instead served directly from memory, drastically reducing the load on the server and latency for the resulting query data to be returned. We will cover a couple ways to avoid returning stale data later in this article.</p>
<p>Exactly what can be optimized with caching is a topic unto itself which I will not delve deeply into here. In general, any heavily used PHP code should at least be benchmarked (both before and after enabling memcached) to see exactly how much it will speed up your code.</p>
<p>I will say that I have seen drastic performance improvement with SQL query intensive code such as social network sites, forums, etc.  If your code makes many SQL queries (and let&#8217;s face it, what dynamic website <em>doesn&#8217;t?</em>), then it is definitely worth trying memcache to see what kind of gains you can achieve. Next, we will see how easy it is to install and use memcached&#8230;</p>
<p><span id="more-98"></span></p>
<h2>Installation:</h2>
<p><span style="color: #ff0000;">Note:</span> this installation was performed on a VPS server (Hosted at <a href="http://rapidvps.com" target="_blank">RapidVPS</a>)  running an <em>updated</em> CentOS 5.7 32-bit. Other platforms or OSs may vary but memcache is fairly easy to install on any platform.</p>
<p>First, make sure libevent is installed:</p>
<p><span class="linux"># yum install libevent</span></p>
<p><code>Since I am running CentOS 5.x 32-bit, I installed the appropriate RPM from pbone.net here:</code></p>
<p><span class="linux"># rpm -Uvh ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/RPMS/memcached-1.4.5-1.el5.kb.i386.rpm<br />
Retrieving ftp://ftp.pbone.net/mirror/centos.karan.org/el5/extras/testing/i386/R                                                                                        PMS/memcached-1.4.5-1.el5.kb.i386.rpm<br />
Preparing&#8230;                ########################################### [100%]<br />
1:memcached              ########################################### [100%]</span><code><br />
</code></p>
<p>&nbsp;</p>
<p>Pretty straightforward, huh?  Now we need to start mcached:</p>
<p><span class="linux">memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody</span></p>
<p>(-d = daemonize  -m 512 = use 512m of RAM for caching  -l = IP to listen on*  -p = port to listen on  -u = user to run as**)</p>
<p>*If you are using memcache <em>only</em> on the same machine as the webserver that will be accessing it, specify 127.0.0.1 (localhost) here for security. Otherwise, specify a <em>public</em> IP on your server so the webserver(s) can reach it.</p>
<p>**It is a good idea to run as the same system user the Apache webserver is running as.</p>
<p>Now, verify memcached is running properly:</p>
<p><span class="linux"># telnet localhost 11211<br />
Trying 127.0.0.1&#8230;<br />
Connected to localhost.<br />
Escape character is &#8216;^]&#8217;.</span><br />
<span class="linux">stats<br />
STAT pid 24214<br />
STAT uptime 21<br />
STAT time 1316571028<br />
STAT version 1.4.5<br />
STAT pointer_size 32<br />
STAT rusage_user 0.000000<br />
STAT rusage_system 0.001999 &#8230;. output truncated</span></p>
<p>Next, we install the php-memcache module and restart Apache<em>:</em></p>
<p><span class="linux"># yum install php-pecl-memcache<br />
# /etc/init.d/httpd restart<br />
</span></p>
<p><em></em>Now Memcached and php-memcache are installed and ready to use!</p>
<p>&nbsp;</p>
<h2>Using memcached in PHP:</h2>
<p>Here is an example of an SQL query function prior to integrating memcache:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="php"><pre class="de1"><span class="kw2">function</span> get_users<span class="br0">&#40;</span><span class="re0">$db</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="re0">$query</span><span class="sy0">=</span><span class="st0">&quot;SELECT * FROM users WHERE 1&quot;</span><span class="sy0">;</span>
    <span class="re0">$result</span> <span class="sy0">=</span> <span class="kw3">mysql_db_query</span><span class="br0">&#40;</span><span class="st0">&quot;user_table&quot;</span><span class="sy0">,</span> <span class="re0">$query</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">return</span> <span class="re0">$result</span><span class="sy0">;</span>
 <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Here is a drop in replacement function call for SQL queries that are frequently used to included them in the memcache:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="php"><pre class="de1"><span class="kw2">function</span> get_users<span class="br0">&#40;</span><span class="re0">$db</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
    <span class="re0">$query</span><span class="sy0">=</span><span class="st0">&quot;SELECT * FROM users WHERE 1&quot;</span><span class="sy0">;</span>
    <span class="re0">$key</span><span class="sy0">=</span><span class="kw3">MD5</span><span class="br0">&#40;</span><span class="re0">$query</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="coMULTI">/* first try the cache */</span>
    <span class="re0">$data</span> <span class="sy0">=</span> <span class="kw3">memcached_fetch</span><span class="br0">&#40;</span><span class="re0">$key</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="re0">$data</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
       <span class="coMULTI">/* not found : request database */</span>
       <span class="re0">$data</span> <span class="sy0">=</span> <span class="kw3">mysql_db_query</span><span class="br0">&#40;</span><span class="st0">&quot;user_table&quot;</span><span class="sy0">,</span> <span class="re0">$query</span><span class="br0">&#41;</span><span class="sy0">;</span>
       <span class="coMULTI">/* then store the result in cache */</span>
       <span class="kw3">memcached_add</span><span class="br0">&#40;</span><span class="re0">$key</span><span class="sy0">,</span> <span class="re0">$data</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
    <span class="kw1">return</span> <span class="re0">$data</span><span class="sy0">;</span>
 <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Now the query result data is stored in the cache with an MD5 signature of the query as the key. So the next time we execute the same query, the memcached_fetch will return the result directly from memory instead of executing the SQL query.</p>
<p>What happens when the <em>users</em> table is updated and we re-run the memcached_fetch? We will be looking at the outdated result as it was when it was added to the cache, without the subsequent updates.</p>
<p>To solve this, we need to update the cache when we update the users table like so:</p>


<div class="wp-geshi-highlight-wrap5"><div class="wp-geshi-highlight-wrap4"><div class="wp-geshi-highlight-wrap3"><div class="wp-geshi-highlight-wrap2"><div class="wp-geshi-highlight-wrap"><div class="wp-geshi-highlight"><div class="php"><pre class="de1"><span class="kw2">function</span> update_users<span class="br0">&#40;</span><span class="re0">$db</span><span class="sy0">,</span> <span class="re0">$update_string</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
   <span class="coMULTI">/* first update database */</span>
    <span class="re0">$result</span><span class="sy0">=</span><span class="kw3">mysql_db_query</span><span class="br0">&#40;</span><span class="st0">&quot;users&quot;</span><span class="sy0">,</span><span class="re0">$update_string</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$result</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
       <span class="coMULTI">/* database update successful : fetch data to be stored in cache */</span>
       <span class="re0">$query</span><span class="sy0">=</span><span class="st0">&quot;SELECT * FROM users WHERE 1&quot;</span><span class="sy0">;</span>
       <span class="re0">$key</span><span class="sy0">=</span><span class="kw3">MD5</span><span class="br0">&#40;</span><span class="re0">$query</span><span class="br0">&#41;</span><span class="sy0">;</span>
       <span class="re0">$data</span> <span class="sy0">=</span> <span class="kw3">mysql_db_query</span><span class="br0">&#40;</span><span class="st0">&quot;user_table&quot;</span><span class="sy0">,</span> <span class="re0">$query</span><span class="br0">&#41;</span><span class="sy0">;</span>
       <span class="coMULTI">/* Now refresh the cache with the updated table */</span>
       <span class="kw3">memcached_add</span><span class="br0">&#40;</span><span class="re0">$key</span><span class="sy0">,</span> <span class="re0">$data</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
 <span class="br0">&#125;</span></pre></div></div></div></div></div></div></div>


<p>Voila. That is memcached in a nutshell. Enjoy the added performance of your busy website!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapidvps.com/2011/optimize-your-php-code-with-memcached-in-centos/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Server Security: Install and Configure CSF on CentOS</title>
		<link>http://blog.rapidvps.com/2011/server-security-install-and-configure-csf-on-centos/</link>
		<comments>http://blog.rapidvps.com/2011/server-security-install-and-configure-csf-on-centos/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 02:55:46 +0000</pubDate>
		<dc:creator>PacketShaper</dc:creator>
				<category><![CDATA[Linux Security]]></category>
		<category><![CDATA[Linux Tools]]></category>
		<category><![CDATA[Network Tools]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[CSF]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://admincheats.com/?p=83</guid>
		<description><![CDATA[Why CSF? CSF is a handy, automated firewall script for securing your server against internet based attacks. CSF can automatically block IP addresses which are trying to gain access to a server providing a first line of defense against internet attacks. This takes a significant workload off the server admin allowing him/her to be able [...]]]></description>
			<content:encoded><![CDATA[<h2>Why CSF?</h2>
<p><a href="http://admincheats.com/wp-content/uploads/2011/09/csf_large.png"><img class="alignright size-full wp-image-84" title="csf_large" src="http://admincheats.com/wp-content/uploads/2011/09/csf_large.png" alt="Install and Configure CSF Firewall on CentOS" width="317" height="127" /></a>CSF is a handy, automated firewall script for securing your server against internet based attacks.</p>
<p>CSF can automatically block IP addresses which are trying to gain access to a server providing a first line of defense against internet attacks. This takes a significant workload off the server admin allowing him/her to be able to focus on further securing the server(s) rather than simply maintaining.</p>
<p><span id="more-83"></span></p>
<h2>Installation:</h2>
<p><span style="color: #ff0000;">Note</span>: this installation was performed on a VPS server (Hosted at <a href="http://rapidvps.com" target="_blank">RapidVPS</a>)  running an <em>updated</em> CentOS 5.7 32-bit.</p>
<p>If you are running a cPanel/WHM Server, please install CSF via the WHM interface.</p>
<p>For all non cPanel servers, start by downloading the tarball and running the install script:</p>
<p><span class="linux"><br />
# wget http://www.configserver.com/free/csf.tgz<br />
# tar -xzf csf.tgz<br />
# cd csf<br />
# sh install.sh<br />
</span></p>
<p>Next, test whether you have the required iptables modules:</p>
<p><span class="linux"># perl /etc/csf/csftest.pl</span></p>
<p>It is ok if some modules fail here as long as there are no FATAL errors.</p>
<p>You can not run any other iptables firewall scripts with CSF without conflicts. If you previously ran APF/PFD, you should uninstall it by running:</p>
<p><span class="linux"># sh /etc/csf/remove_apf_bfd.sh</span></p>
<p>Make sure klogd is enabled. Edit /etc/init.d/syslog and make sure all klogd lines are not commented out.<br />
Restart syslog if you make any changes in that file:<br />
<span class="linux"># /etc/init.d/syslog restart</span></p>
<h2>Configuration:</h2>
<p>Add any IPs you wish to whitelist to &#8220;/etc/csf.allow&#8221; and any IPs you wish to blacklist to &#8220;/etc/csf.deny&#8221;</p>
<p>Now, edit &#8220;/etc/csf/csf.conf&#8221; and make any changes to the allowed in/out ports lists as necessary for your environment.<br />
Leave &#8220;testing&#8221; set to 1 for now.</p>
<p>Restart CSF with:<br />
<span class="linux"># /etc/init.d/csf restart</span></p>
<p>Test all your daemons / applications and ensure everything is working correctly.</p>
<p>If everything is good, edit &#8220;/etc/csf/csf.conf&#8221; and change &#8220;TESTING&#8221; to 0 and restart again to go live with CSF:<br />
<span class="linux">/etc/init.d/csf restart</span></p>
<p>Now that CSF is running, to be truly useful we need to know how to easily whitelist/blacklist IPs on the fly and also how to find out if/why an IP has been automatically blacklisted.<br />
(For the examples below, obviously you will need to substitute the target IP for X.X.X.X)</p>
<p>To <strong>Whitelist</strong> an IP:<br />
<span class="linux"># csf -a X.X.X.X</span></p>
<p>To <strong>Blacklist</strong> an IP:<br />
<span class="linux"># csf -d X.X.X.X</span></p>
<p>And to find out if an IP has been dropped and why:<br />
<span class="linux"># grep X.X.X.X /etc/csf.deny</span></p>
<p>If the IP in question is listed in this file, it will be accompanied by the reason the IP was added to the blacklist, such as too many SSH or FTP failed login attempts.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapidvps.com/2011/server-security-install-and-configure-csf-on-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Minute Netflow Guide</title>
		<link>http://blog.rapidvps.com/2011/10-minute-netflow-guide/</link>
		<comments>http://blog.rapidvps.com/2011/10-minute-netflow-guide/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 03:36:01 +0000</pubDate>
		<dc:creator>PacketShaper</dc:creator>
				<category><![CDATA[Network Security]]></category>
		<category><![CDATA[Optimizations]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[mls]]></category>
		<category><![CDATA[netflow]]></category>
		<category><![CDATA[netflow sampling]]></category>
		<category><![CDATA[network traffic]]></category>
		<category><![CDATA[sampling]]></category>
		<category><![CDATA[toptalkers]]></category>

		<guid isPermaLink="false">http://rapidvps.com/sfair411/?p=5</guid>
		<description><![CDATA[This guide was originally written by Rick Blundell and was formerly hosted at NetflowGuide.com The purpose of this guide is to promote the education and use of Cisco&#8217;s Netflow Technology. Netflow allows network engineers and hobbyists to accurately and efficiently export network statistics for evaluation and report generation. A well written Netflow capture and scanner [...]]]></description>
			<content:encoded><![CDATA[<p>This guide was originally written by <strong>Rick Blundell</strong> and was formerly hosted at <strong>NetflowGuide.com</strong></p>
<p>The purpose of this guide is to promote the education and use of Cisco&#8217;s Netflow Technology. Netflow allows network engineers and hobbyists to accurately and efficiently export network statistics for evaluation and report generation. A well written Netflow capture and scanner system permits one to analyze current network usage and plan for necessary network growth.</p>
<p style="text-align: center;"><a href="http://admincheats.com/wp-content/uploads/2011/09/netflowexample1.png"><img class="aligncenter size-full wp-image-10" title="NetflowExample" src="http://admincheats.com/wp-content/uploads/2011/09/netflowexample1.png" alt="Netflow Example" width="501" height="247" /></a><a href="http://admincheats.com/wp-content/uploads/2011/09/netflowexample.png"><br />
</a></p>
<p>Netflow Technology is currently employed at universities, datacenters, and office networks.</p>
<p>What is Netflow  useful for?</p>
<table border="0">
<tbody>
<tr>
<td>
<ul>
<li>Bandwidth accounting</li>
<li>Accessing network consumption by subnet/host/protocol/service</li>
<li>Bandwidth billing</li>
</ul>
</td>
<td>
<ul>
<li>RRDTool database backend</li>
<li>Directly Integrates wtih Cisco Netflow Technology</li>
<li>Can be used with any netflow export device</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>What can questions can Netflow answer?</p>
<table border="0">
<tbody>
<tr>
<td>
<ul>
<li>What are the top 10 bandwidth consumers?</li>
<li>How many Gigabytes did IP xx.xx.xxx.xxx use in the last 30 days?</li>
<li>How much IRC and Filesharing traffic is on our network?</li>
</ul>
</td>
<td>
<ul>
<li>Is IP xx.xx.xxx.xxx sending an unusually high amount of packets?</li>
<li>What are our maximum and average bandwidth users?</li>
<li>Is our network large enough to support our traffic?</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><span id="more-5"></span><br />
<span style="color: #ff0000;">Note</span>: this installation was performed on a VPS server (Hosted at <a href="http://rapidvps.com" target="_blank">RapidVPS</a>)  running an <em>updated</em> CentOS 5.7 32-bit.</p>
<p>First, let&#8217;s make the directories netflow will store data:<br />
<span class="linux"><br />
# mkdir -p /var/netflow/flows<br />
# mkdir -p /var/netflow/rrds<br />
# mkdir -p /var/netflow/reports/scoreboard<br />
# useradd netflow<br />
# chown netflow.netflow /var/netflow/ -R<br />
</span></p>
<p>Add the RPMForge Repo:  (Note: if you are running a 64 bit system, you will need the 64 bit repo package instead of this one)</p>
<p><span class="linux"># rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm</span></p>
<p>Update system packages and install required packages via installed repos.<br />
<span class="linux"><br />
# yum -y update<br />
# yum -y install httpd perl perl-HTML-Table perl-Net-Patricia perl-XML-Parser rrdtool pdksh<br />
</span></p>
<p>Install remaining Perl modules and Flow-Tools via 3rd party Repos<br />
<span class="linux"><br />
# rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/perl-ConfigReader-0.5-1.el5.rf.noarch.rpm</p>
<p># rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/perl-Boulder-1.30-3.el5.noarch.rpm</p>
<p># rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/perl-Cflow-1.053-6.el5.i386.rpm</p>
<p># rpm -Uvh http://centos.alt.ru/repository/centos/5/i386/flow-tools-0.68.5-1.el5.i386.rpm</p>
<p></span></p>
<p>Install FlowScan:<br />
<span class="linux"><br />
# wget http://net.doit.wisc.edu/~plonka/FlowScan/FlowScan-1.006.tar.gz<br />
# tar -zxvf FlowScan-1.006.tar.gz<br />
# cd FlowScan-1.006<br />
# ./configure &#8211;prefix=/var/netflow<br />
# make install<br />
# cp cf/* /var/netflow/bin<br />
</span></p>
<p>Install CUFlow:<br />
<span class="linux"><br />
# wget http://www.columbia.edu/acis/networks/advanced/CUFlow/CUFlow-1.7.tgz<br />
# tar -zxvf CUFlow-1.7.tgz<br />
# cd CUFlow-1.7<br />
# cp CU* /var/netflow/bin/<br />
</span><br />
Download start scripts for flow-capture and flowscan and an updated version of FlowScan.pm:</p>
<p><span class="linux"></p>
<p>wget http://admincheats.com/files/support-files-1.0.tar.gz<br />
tar -zxvf support-files-1.0.tar.gz<br />
cd support-files-1.0<br />
cp flow* /etc/init.d/<br />
cp FlowScan.pm /var/netflow/bin<br />
</span></p>
<p><!--more--></p>
<p>Configure Flow-Capture:<br />
<span class="linux"># vi /etc/sysconfig/flow-capture</span></p>
<p>OPTIONS=&#8221;-n 287 -N 0 -w /var/netflow/flows -S 5 0/0/8818&#8243;</p>
<p>Split flows into new files every 5 min and keep in one dir&#8230; they are deleted after processing.<br />
The last number (8818 here) is the port flow-capture will listen for data on. This must match the port you configure in your router(s) for export data.</p>
<p>Configure CUFlow:<br />
<span class="linux"><br />
# vi /var/netflow/bin/CUFlow.cf<br />
</span></p>
<p>-Define your Subnets, one per line  e.g., &#8220;Subnet 10.0.0.0/24&#8243;<br />
-Update OutputDir to /var/netflow/rrds<br />
-Update ScoreBoard and AggregateScore paths.  i.e.<br />
Scoreboard 30 /var/netflow/reports/scoreboard /var/www/html/toptalkers.php<br />
AggregateScore 30 /var/netflow/reports/scoreboard/agg.dat /var/www/html/overall.php</p>
<p>Configure Flowscan:<br />
<span class="linux">    vi /var/netflow/bin/flowscan.cf </span><br />
-change the &#8220;FlowFileGlob&#8221; line to &#8220;FlowFileGlob /var/netflow/flows/ft-v05.*&#8221;<br />
-change the ReportClasses variable to &#8220;CUFlow&#8221;</p>
<p>Next, we will configure our Cisco 6500 routers running IOS 12.2 to export the Netflow data to our collector.<br />
The syntax may be slightly different for other versions or platforms.</p>
<p>Global config commands:<br />
<span class="linux">Router(config)#ip flow-export source Loopback0</span><br />
You can change the source interface to suit your needs.<br />
<span class="linux">Router(config)#ip flow-export version 5 peer-as<br />
Router(config)#ip flow-export destination x.x.x.x yyy</span></p>
<p><strong>x.x.x.x</strong> is the IP address of our collector server and <strong>yyy</strong> is the port to send the data to.<br />
<span class="linux"><br />
Router(config)#ip flow-cache timeout active 1</span><br />
Now, on each edge interface, enable accouting collection:<br />
<span class="linux">Router(config)#ip route-cache flow</span></p>
<p>&nbsp;</p>
<p>If you are running a software or hardware firewall in front of your collector box, don&#8217;t forget to open the UDP port you specified above to allow the netflow data to reach the server.</p>
<p>&nbsp;</p>
<p><!--more--></p>
<p>To verify you are receiving netflow packets from your router(s), run this command (assuming you configured port 8818 for your router export above)<br />
<span class="linux"># tcpdump -n udp port 8818</span><br />
You should see packets from each router you configured to export netflow data.</p>
<p>Start flow-capture:<br />
<span class="linux"># /etc/init.d/flow-capture start</span></p>
<p>Now you should see a tmp file created in /var/netflow/flows/ and after 5 minutes, this file will be renamed to something like ft-v05.2011-09-17.232001-0400</p>
<p>Now that the flow file has been finalize (and a new tmp file created for collecting new data), it can be processed by flowscan.<br />
Initially, we will start flowscan manually to verify everything is working properly:<br />
<span class="linux"># cd /var/netflow<br />
# bin/flowscan </span></p>
<p>Assuming there are no errors here, the flow file should be processed and the RRD files updated. You should also notice a new file /var/www/html/toptalkers.php<br />
You can view this page by visiting your servers DocRoot page. i.e. http://192.168.2.23/toptalkers.php (obviously you will have to substitute your own IP in the URL).<br />
Lastly, start flowscan via the init script so it runs continuously:<br />
<span class="linux"># /etc/init.d/flowscan start</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapidvps.com/2011/10-minute-netflow-guide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why NAT is BAD for Servers</title>
		<link>http://blog.rapidvps.com/2011/why-nat-is-bad-for-servers/</link>
		<comments>http://blog.rapidvps.com/2011/why-nat-is-bad-for-servers/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 00:03:07 +0000</pubDate>
		<dc:creator>PacketShaper</dc:creator>
				<category><![CDATA[Advice]]></category>
		<category><![CDATA[Linux Optimizations]]></category>
		<category><![CDATA[Linux Security]]></category>
		<category><![CDATA[Network Security]]></category>
		<category><![CDATA[Optimizations]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[NAT]]></category>
		<category><![CDATA[network address translation]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[server security]]></category>

		<guid isPermaLink="false">http://admincheats.com/?p=11</guid>
		<description><![CDATA[NAT is short for Network Address Translation As a network consultant, I design and implement computer networks of all sizes for clients on a regular basis. All too often, the clients request that their servers utilize a NAT setup. I always ask why they think they need NAT, and I am always surprised at the [...]]]></description>
			<content:encoded><![CDATA[<p>NAT is short for <a href="http://en.wikipedia.org/wiki/Network_address_translation" target="_blank">Network Address Translation</a></p>
<p>As a network consultant, I design and implement computer networks of all sizes for clients on a regular basis. All too often, the clients request that their servers utilize a NAT setup.</p>
<p>I always ask why they think they need NAT, and I am always surprised at the answer. Either the client has been told (by someone, at some time in the past) that NAT &#8220;is just better&#8221; for some reason, or they cite &#8220;security&#8221; concerns. This always makes me chuckle as NAT was never intended to provide security.</p>
<p>The fact is, NAT can actually make public facing servers LESS secure in a couple ways.</p>
<p><span id="more-11"></span></p>
<p>First, when NAT is used in place of a thorough and well-planned security policy (as is usually the case) it leaves machines open to malware which is downloaded by someone directly on the machine. Perhaps a sysadmin uses Internet Explorer to download some utility to the server but visits a site with hidden malware (this happens more than you would believe). Now once the malware executes, it &#8220;phones home&#8221; to the attackers server, opening a path back through the stateful NAT device to the compromised server. Now the attacker has total control of the server and the server owner is none the wiser. If you think this attack vector is unlikely, think again. I have personally seen this type of intrusion several times in the last month alone, on multiple different networks. This is due to server admins incorrectly believing NAT provides some mythical level of security and not having an adequate additional security policy in place. The best policy when setting up a firewall is to explicitly open only the necessary ports for a server BOTH inbound AND outbound. Outbound is often overlooked, but that is how this attack vector works in the wild. The oubound connection is the first step to gaining control of the machine. Without that, the attack is dead.</p>
<p>The other way NAT can make servers less secure is it is terribly complicated and can lead to simple human error. It is very easy for novice network administrators to have a working NAT policy at one point and need to make a change. This can be much more complicated with a NAT setup than with a regular public IP scheme. When the change does not work as expected, firewall rules and access lists may be &#8220;temporarily&#8221; disabled to allow for troubleshooting of the NAT setup. All too often, these rules are left &#8220;open&#8221; once the underlying problem is resolved and the servers are left partially or completely unprotected. Likewise, with a complex NAT setup, it can also be difficult to verify all rules are correctly back in place and everything is secure again. It goes back to the old mantra, &#8220;Keep It Simple, Stupid&#8221;. Complexity should be avoided whenever possible and NAT falls neatly into that category.</p>
<p>The truth of the matter is that NAT was never intended to provide security at all. It was intended to reduce the need for public IPs on devices which do not need full end-to-end connectivity. Internet servers do NOT fall into this category unless they do not need ANY access to the internet (i.e. Database servers which are only accessed by a webserver directly on private IPs). For all other servers, a sane public IP numbering scheme along with an intelligent inbound AND outbound security policy is much more secure and easier to maintain than NAT ever could be.</p>
<p>Friends don&#8217;t let friends NAT their servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rapidvps.com/2011/why-nat-is-bad-for-servers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

