Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Cedric Blancher <blancher@cartel-securite.fr>
To: Matthew Donofrio <mdonof2@pride.hofstra.edu>
Cc: netfilter@lists.netfilter.org
Subject: Re: How exactly does RELATED work in Connection Tracking?
Date: 23 Oct 2002 00:21:17 +0200	[thread overview]
Message-ID: <1035325277.10494.18.camel@elendil> (raw)
In-Reply-To: <000801c2798e$a7dcfd70$09c809c0@PENT4>

Le mar 22/10/2002 à 07:48, Matthew Donofrio a écrit :
> I'm trying to determine how exactly an incoming packet is determined
> to be RELATED to an existing connection in Connection Tracking. For
> instance, how exactly does a TCP connection know that the packet is
> starting a new connection and this should be deemed RELATED?  What
> fields (for lack of a better word) are compared to come to this
> conclusion?

I am no Netfilter developper, but this is what I understood from all
I've read on the subject.

Connection tracking relies on data structures. In those, to be quick,
you have tuples that are used to recognise packets going both ways. A
tuple is a set of datas that caracterize a packet for Netfilter. Theses
tuples are used firstly to build conntrack table entries, and then to
try to match theses entries against further packets. That means when you
see a packet, you can calculate its own tuple, and then compare it to
the ones that are in data structures that represent current conntracked
flows.

When you load an ip_conntrack module, such as ip_conntrack_ftp, it
starts to look at specific network flows. For FTP conntrack, it looks at
every TCP connection destined to port 21. Then, it tries to spot data
connection negociation into them (PORT and OK that follows PASSIVE).
When spot, theses commands are parsed, and a tuple is extracted to match
the first packet of the rekated connection. As an example, when you see
parameters associated to PORT command, you are able to exactly know what
packet will initiate data connection. This extracted tuple is called an
expectation.

When a packet reaches the box, then Netfilter looks at it, extract from
the header its own tuple and then compares it to known tuples that are
part of current conntracked connections. If it matches one of theses
tuples, then it is ESTABLISHED. It is also compared to all expectations.
If it matches one expectation, then we know this packet is RELATED (and
if it does not match anything, it is NEW). Then, we can create a new
structure for him with tuples and so on and treat the flow as others.


Hope this 2 cents of euro will help you ;)

-- 
Cédric Blancher  <blancher@cartel-securite.fr>
IT systems and networks security expert  - Cartel Sécurité
Phone : +33 (0)1 44 06 97 87 - Fax: +33 (0)1 44 06 97 99
PGP KeyID:157E98EE  FingerPrint:FA62226DA9E72FA8AECAA240008B480E157E98EE


  reply	other threads:[~2002-10-22 22:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-22  5:48 How exactly does RELATED work in Connection Tracking? Matthew Donofrio
2002-10-22 22:21 ` Cedric Blancher [this message]
2002-10-23 15:57   ` Matthew Donofrio
2002-10-23 13:26     ` Cedric Blancher
2002-10-24 10:06     ` Antony Stone

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=1035325277.10494.18.camel@elendil \
    --to=blancher@cartel-securite.fr \
    --cc=mdonof2@pride.hofstra.edu \
    --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