old-www/LDP/LG/issue13/filter.html

125 lines
4.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>Title of Article Issue 13</title>
</HEAD>
<BODY >
<H4>
&quot;Linux Gazette...<I>making Linux just a little more fun!</I>
&quot;</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<h1>Filtering Advertisements from Web Pages using IPFWADM</h1>
<H4>By David Rudder
<a href="mailto:drig@magicweb.com">drig@magicweb.com</a></H4>
</center>
<P> <HR> <P>
Lately, a lot of Web pages have begun selling ad space &quot;banners.&quot;
Wasting valuable bandwidth, these banners often hawk products I don't
care to hear about. I'd rather not see them, and not have to download
their contents.
<p>
There are two ways of filtering out these banners. The first is to
deny all pictures that are wider than tall and generally towards the
top or bottom of the page. The second is to simply block all the
accesses to and from the web sites that are the notorious advertisers.
This second approach is the one I'm going to take.
<p>
When searching around the web, you will see that many of the banners
come from the site ad.linkexchange.com. This is the site we will want
to ban.
<P> <HR> <P>
<center><h3>Setting Up Your Firewall</h3></center>
<p>
Our first order of business is to set up our firewall. We won't be
using it for security, although this doesn't prohibit also using the
firewall for security. First, we recompile the kernel, saying
&quot;Yes&quot;
to CONFIG_FIREWALL. This allows us to use the built in kernel
firewalling.
<p>
Then, we need to get the IPFWADM utility. You can find it at:
<a
href="http://www.xos.nl/linux/ipfwadm">http://www.xos.nl/linux/ipfwadm
</a>. Untar, compile and install this utility.
<p>
Since we are doing no other firewalling, this should be sufficient.
</p>
<P> <HR> <P>
<center><h3>Blocking Unwanted Sites</h3></center>
<p>
Now, we come to the meat of the maneuver. We need now to block access
to our machine from ad.linkexchange.com. First, block out access to
the sight, so that our requests don't even make it there.
<tt>ipfwadm -O -a reject -P tcp -S 0.0.0.0/0 -D ad.linkexchange.com 80</tt><br>
<p>
This tells ipfwadm to append a rule to the Output filter. The rule
says to reject all packets of protocol TCP from anywhere to
ad.linkexchange.com on port 80. If you don't get this, read Chris
Kostick's excellent article on IP firewalling at
<a href="http://www.ssc.com/lj/issue24/1212.html">
http://www.ssc.com/lj/issue24/1212.html</a>.
<p>
The next rule is to keep any stuff from ad.linkexchange.com from
coming in. Technically, this shouldn't be necessary. If we haven't
requested it, it shouldn't come. But, better safe than sorry.
<tt>ipfwadm -I -a reject -P tcp -S ad.linkexchange.com 80 -D 0.0.0.0/0</tt><br>
<p>
Now, all access to and from ad.linkexchange.com is rejected.
<p>
<em>Note:</em> this will only work when web browsing from that machine. To
filter for a whole network, do them same but with -F instead of -O and
-I.
<P> <HR> <P>
<center><h3>Testing It Out</h3></center>
<p>
To test, visit the site <a href="http://www.reply.net">http://www.reply.net</a>. They have a banner on
top which should either not appear or appear as a broken icon. Either
way, no network bandwidth will be wasted downloading the picture, and
all requests will be rejected immediately.
</p>
<P> <HR> <P>
<center><h3>Filling It Out</h3></center>
<p>
Not all banners are so easily dealt with. Many companies, like Netscape, host their
own banners. You don't want to block access to Netscape, so this
approach won't work. But, you will find a number of different
advertisers set up like linkexchange. As you find more, add them to
the list of rejected sites.
</p>
Good luck, and happy filtering!
<P> <hr> <P>
<center><H5>Copyright &copy; 1997, David Rudder <BR>
Published in Issue 13 of the Linux Gazette</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./comdex.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./floppies.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
</BODY>
</HTML>