Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "Rodre Ghorashi-Zadeh" <rodrico7@hotmail.com>
To: gdamjan@mail.net.mk, netfilter@lists.netfilter.org
Subject: Re: Howto match only the first connection from an IP
Date: Wed, 19 Nov 2003 00:04:14 +0000	[thread overview]
Message-ID: <Law14-F99vOSQeSOzNC0001fd0b@hotmail.com> (raw)

Hello,

I don't think this will work for all traffic, but it should for TCP based 
traffic. Assuming the first packet is a
"SYN" packet, you could try:

iptables -t nat -p tcp --syn --dport 80 -s 171.68.1.1 -m quota --quota 40 \
     -j REDIRECT --to-ports 9999

the key here is the "--syn" flag on the TCP protocol (-p tcp)

Good luck

®odre

>From: Damjan <gdamjan@mail.net.mk>
>To: netfilter@lists.netfilter.org
>Subject: Re: Howto match only the first connection from an IP
>Date: Tue, 18 Nov 2003 18:26:02 +0100
>
> > > My goal is to set-up an iptables rule that will match and DNAT the
> > > first HTTP(port 80) connection from a client (IP address).
> > >
> > > The first connection is defined as the first established TCP session
> > > from the time the iptables rule is inserted. No other TCP connection
> > > should match nor should be DNAT-ed.
> > >
> > > Is there any easy way to do this with current Netfilter/Iptables/pom.
> >
> > I can't think of a way to do this with netfilter on its own.
>
>Well I've come to this solution, but I wonder how reliable it is
>
>iptables -t nat -p tcp --dport 80 -s 171.68.1.1 -m quota --quota 40 \
>     -j REDIRECT --to-ports 9999
>
>This seems to match only the first connection.
>
>Any other ideas???
>
>--
>Damjan Georgievski
>jabberID: damjan@bagra.net.mk
>

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



             reply	other threads:[~2003-11-19  0:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-19  0:04 Rodre Ghorashi-Zadeh [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-11-20 21:55 Howto match only the first connection from an IP George Vieira
2003-11-18 14:43 Damjan
2003-11-18 16:00 ` Antony Stone
2003-11-18 17:26   ` Damjan
2003-11-18  5:12 Damjan

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=Law14-F99vOSQeSOzNC0001fd0b@hotmail.com \
    --to=rodrico7@hotmail.com \
    --cc=gdamjan@mail.net.mk \
    --cc=netfilter@lists.netfilter.org \
    /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