<?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>Just answer the F*#king question &#187; Linux</title>
	<atom:link href="http://www.jatfq.com/archives/category/usefull-stuff/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jatfq.com</link>
	<description></description>
	<lastBuildDate>Fri, 06 Aug 2010 13:05:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using IPtables and PHP to block SPAM/DOS</title>
		<link>http://www.jatfq.com/archives/130</link>
		<comments>http://www.jatfq.com/archives/130#comments</comments>
		<pubDate>Thu, 08 Jul 2010 01:30:53 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/?p=130</guid>
		<description><![CDATA[Had some issues with bots hammering one of my servers. For a while I was blocking by hand and returning 404 errors, with a simple 404 redirect, however, this will still used up resources and http / apache threads. This is a very basic method that was implemented to stop spammers from your site. You [...]]]></description>
			<content:encoded><![CDATA[<p>Had some issues with bots hammering one of my servers. For a while I was blocking by hand and returning 404 errors, with a simple 404 redirect, however, this will still used up resources and http / apache threads.</p>
<p>This is a very basic method that was implemented to stop spammers from your site. You could modify this to be a bit more intelligent, in this case I have a &#8220;honeypot&#8221; page that only the spammers and bad bots seem to access plus a few sanity checks just incase google visits by accident, however, you could put a counter in to a DB or do some other simple checking before triggering the firewall.  </p>
<p>First step, you need to use visudo to allow apache ( or www-data ) access to iptables.</p>
<p><code>visudo</code></p>
<p>and then add the following line</p>
<p><code>apache ALL = NOPASSWD: /sbin/iptables -I INPUT -m iprange --src-range * -j DROP</code></p>
<p>Replace &#8220;apache&#8221; with www-data if needed ( if you are unsure, do a <code>ps -al | grep apache </code> or  <code>ps -al | grep httpd</code> ) and get the user &#8230; we hope apache is not running as root.</p>
<p>This will allow the apache user access to the specific command above. You could probably lock this down more if needed.</p>
<p>Exit out, and then add the following to your &#8220;honeypot&#8221; page</p>
<p><code>exec("sudo /sbin/iptables -I INPUT -m iprange --src-range ".$REMOTE_ADDR."-".$REMOTE_ADDR." -j DROP");</code></p>
<p>Now, obviously <strong>DON&#8217;T TEST THIS FROM YOUR OWN IP</strong>. Otherwise your going to block yourself from your server. To test, hardcode a different IP in there or do it from another public IP. </p>
<p>So, hopefully, the next time a spammy IP comes and touches your IP address, they will be locked right out. If someone gets blocked by accident, do a <code>sh /etc/init.d/iptables save</code> then edit the saved files ( normally /<code>etc/sysconfig/iptables </code>) to remove the DROP command for that IP and then <code>sh /etc/init.d/iptables restart</code></p>
<p>You could also modify the code to block a bigger range of IP&#8217;s by padding the range to the class C address or more depending on what level of activity you are getting.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F130&amp;title=Using+IPtables+and+PHP+to+block+SPAM%2FDOS" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/130/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check number of open connections by IP address</title>
		<link>http://www.jatfq.com/archives/128</link>
		<comments>http://www.jatfq.com/archives/128#comments</comments>
		<pubDate>Tue, 06 Jul 2010 15:11:49 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/archives/128</guid>
		<description><![CDATA[netstat -ntu &#124; awk '{print $5}' &#124; cut -d: -f1 &#124; sort &#124; uniq -c &#124; sort -n]]></description>
			<content:encoded><![CDATA[<p><code>netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n</code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F128&amp;title=Check+number+of+open+connections+by+IP+address" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/128/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check maximum number of open files</title>
		<link>http://www.jatfq.com/archives/126</link>
		<comments>http://www.jatfq.com/archives/126#comments</comments>
		<pubDate>Mon, 17 May 2010 11:28:19 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/?p=126</guid>
		<description><![CDATA[Use ulimit -a. To set use sudo ulimit -n, to keep put into your /root/.bashrc script.]]></description>
			<content:encoded><![CDATA[<p>Use <code>ulimit -a</code>. To set use <code>sudo ulimit -n</code>, to keep put into your /root/.bashrc script.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F126&amp;title=Check+maximum+number+of+open+files" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/126/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capturing frames of ASX / MMS stream with MPlayer</title>
		<link>http://www.jatfq.com/archives/116</link>
		<comments>http://www.jatfq.com/archives/116#comments</comments>
		<pubDate>Wed, 20 Jan 2010 15:57:08 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/?p=116</guid>
		<description><![CDATA[This will allow you to capture a single frame from a ASX / ASF / MMS stream. Be aware if the ASX contains more than 1 file, you will get more than 1 screen capture. Also remember to use the playlist option for ASX streams mplayer -playlist http://xxxxx -ss 1 -frames 1 -vo jpeg When [...]]]></description>
			<content:encoded><![CDATA[<p>This will allow you to capture a single frame from a ASX / ASF / MMS stream.  Be aware if the ASX contains more than 1 file, you will get more than 1 screen capture. Also remember to use the <code>playlist</code> option for ASX streams</p>
<p><code>mplayer -playlist http://xxxxx -ss 1 -frames 1 -vo jpeg</code></p>
<p>When building mplayer you will need <code>libjpeg</code> &#8211; do <code>mplayer -vo help</code> to list available output options.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F116&amp;title=Capturing+frames+of+ASX+%2F+MMS+stream+with+MPlayer" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/116/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count number of open files in LINUX</title>
		<link>http://www.jatfq.com/archives/114</link>
		<comments>http://www.jatfq.com/archives/114#comments</comments>
		<pubDate>Wed, 09 Dec 2009 14:41:25 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/archives/114</guid>
		<description><![CDATA[lsof &#124; wc -l]]></description>
			<content:encoded><![CDATA[<p><code> lsof  | wc -l</code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F114&amp;title=Count+number+of+open+files+in+LINUX" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/114/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
