Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Joel Newkirk <netfilter@newkirk.us>
To: Karl Gruber <sysadmin@hnoe1.sth.ac.at>, netfilter@lists.netfilter.org
Subject: Re: redirect a HTTP-connection only once
Date: Sat, 16 Nov 2002 12:11:31 -0500	[thread overview]
Message-ID: <200211161211.31119.netfilter@newkirk.us> (raw)
In-Reply-To: <200211152128.58239.sysadmin@hnoe1.sth.ac.at>

On Friday 15 November 2002 03:28 pm, Karl Gruber wrote:
> Hi!
>
> I want to know if it is possible that an iptables-rule matches only once. I
> want to implement a redirection of the first http-request of an user.
>
> thanx,
>      Karl

disclaimer - I've never done this before...

Do you mean the first ever (IE only catch one, then never again) or the first 
to a given destination, or what? 

Matching TCP80 from a user with state NEW and TCP flag SYN without ACK or RST 
should catch the initial HTTP request in a given transaction, and repeat 
every time a new request is initiated.  I believe a LIMIT match (1/day) with 
no burst watching for these would catch only the first HTTP transaction 
requested by a user each day. (or until the firewall is reset, whichever is 
sooner)  

But the packet itself will probably be effectively lost if you redirect only 
the first, leaving the client to re-request.  If you divert a single packet 
then reinsert it somehow, I think netfilter will not properly handle 
forwarding of subsequent packets that are part of the transaction.

Something like:

/sbin/iptables -A FORWARD -s w.x.y.z -p tcp --dport 80 --state NEW --tcp-flags 
SYN,RST,ACK SYN -m limit --limit 1/day --limit-burst 1 -j {whatever target}

Should match ONLY the first request from w.x.y.z for an HTTP connection per 
day.  Would that suit your use?

j


  reply	other threads:[~2002-11-16 17:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-15 20:28 redirect a HTTP-connection only once Karl Gruber
2002-11-16 17:11 ` Joel Newkirk [this message]
2002-11-19  6:47 ` arptables Toshihiro Sonoda
2002-11-22 10:18   ` arptables Cedric Blancher
2002-11-22 16:01     ` arptables Ben Russo
2002-11-22 16:54       ` routing with the iptables Rimas
2002-11-19 17:03 ` Test (I am not recieving mails since 15.11.2002) Erdal Mutlu
2002-11-20 10:38 ` Test: is this list alive Erdal Mutlu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211161211.31119.netfilter@newkirk.us \
    --to=netfilter@newkirk.us \
    --cc=netfilter@lists.netfilter.org \
    --cc=sysadmin@hnoe1.sth.ac.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox