<?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>Guy Rutenberg &#187; ufw</title>
	<atom:link href="http://www.guyrutenberg.com/tag/ufw/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Blocking IP Range using UFW</title>
		<link>http://www.guyrutenberg.com/2009/11/07/blocking-ip-range-using-ufw/</link>
		<comments>http://www.guyrutenberg.com/2009/11/07/blocking-ip-range-using-ufw/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 19:19:15 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ufw]]></category>

		<guid isPermaLink="false">http://www.guyrutenberg.com/?p=584</guid>
		<description><![CDATA[Uncomplicated Firewall (ufw) is one of the greatest frontends to IPTables I&#8217;ve encountered. It is very simple to use and I just wish it was also available for Gentoo. Up until recently everything went smoothly for me and ufw, but we hit some rough waters when I&#8217;ve tried to block an IP range.
To block an [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://launchpad.net/ufw">Uncomplicated Firewall</a> (<code>ufw</code>) is one of the greatest frontends to IPTables I&#8217;ve encountered. It is very simple to use and I just wish it was also available for Gentoo. Up until recently everything went smoothly for me and <code>ufw</code>, but we hit some rough waters when I&#8217;ve tried to block an IP range.</p>
<p>To block an ip or I&#8217;p range in ufw you should do</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo ufw deny from 188.162.67.197/21</pre></div></div>

<p><span id="more-584"></span></p>
<p>But here is the catch. Only the recent versions of <code>ufw</code> (which the version that comes with Ubuntu 8.04 isn&#8217;t one of them) support inserting new rules. When you add a rule it gets appended. So if you had a rule before that allows everyone to connect to your server on port 80, it also allows the IP range you&#8217;re trying to block, to connect to your machine.</p>
<p>As it&#8217;s impossible to foresee all the rules you might use, one has to resort to deleting all the rules he has to override, then re-add them so they will be after the rule that blocks the IP range. However I disliked the idea and looked for a simpler solution.</p>
<p>The easiest method I&#8217;ve found was to manully edit <code>ufw</code>&#8217;s configurations:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo vim /var/lib/ufw/user.rules</pre></div></div>

<p>And then move the rule I&#8217;ve added, which looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">### tuple ### deny any any 0.0.0.0/0 any 188.162.67.197/21
-A ufw-user-input -s 188.162.67.197/21 -j DROP</pre></div></div>

<p>above any other rules in the configuration file.</p>
<p>Afterward, you&#8217;ll have to restart <code>ufw</code> so it will reload its configurations.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo ufw disable
sudo ufw enable</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2009/11/07/blocking-ip-range-using-ufw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.377 seconds -->
