All of lore.kernel.org
 help / color / mirror / Atom feed
* Parsing conntrack entries
@ 2015-01-01 22:14 Dennis Jacobfeuerborn
  2015-01-02  0:10 ` Karsten Hohmeier
  2015-01-03  7:51 ` Hendrik Visage
  0 siblings, 2 replies; 4+ messages in thread
From: Dennis Jacobfeuerborn @ 2015-01-01 22:14 UTC (permalink / raw)
  To: netfilter

Hi,
I'm trying to write a small python script that creates some statistics
from the current conntrack entries of a system. The problem I've run
into is that I cannot find a good description of the output format of
the conntrack tool and while I initially though the format is reasonably
straightforward to deduce I ran into some snags.

The format of a line not only changes with protocol and entry state but
even entries with the same protocol and state seem to have different
formats:

tcp      6 3 CLOSE src=<IP1> dst=<IP2> sport=X dport=Y src=<IP2>
dst=<IP1> sport=Y dport=X mark=0 use=1

vs

tcp      6 3 CLOSE src=<IP1> dst=<IP2> sport=X dport=Y src=<IP2>
dst=<IP1> sport=Y dport=X [ASSURED] mark=0 use=1

Why does one entry contain the [ASSURED] but the other does not?

Also for some connections I see the [ASSURED] near the end of the line
but for others I see an [UNREPLIED] in the *middle* of the line and no
flag near the end of the line.

What is the meaning of the "use" field?

What is the best way to parse this information in a reliable way?

Regards,
  Dennis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Parsing conntrack entries
  2015-01-01 22:14 Parsing conntrack entries Dennis Jacobfeuerborn
@ 2015-01-02  0:10 ` Karsten Hohmeier
  2015-01-02  0:26   ` Stig Thormodsrud
  2015-01-03  7:51 ` Hendrik Visage
  1 sibling, 1 reply; 4+ messages in thread
From: Karsten Hohmeier @ 2015-01-02  0:10 UTC (permalink / raw)
  To: netfilter

Hi Dennis,

> What is the best way to parse this information in a reliable way?

Maybe you could try dumping the table in XML as mentioned by the manpage?

conntrack -L -o xml
    Dump the connection tracking table in XML

Best Regards

Karsten


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Parsing conntrack entries
  2015-01-02  0:10 ` Karsten Hohmeier
@ 2015-01-02  0:26   ` Stig Thormodsrud
  0 siblings, 0 replies; 4+ messages in thread
From: Stig Thormodsrud @ 2015-01-02  0:26 UTC (permalink / raw)
  To: Karsten Hohmeier; +Cc: netfilter

I wrote this script to parse nat translations, maybe it could be a
starting point.
https://github.com/vyos/vyatta-nat/blob/lithium/scripts/vyatta-nat-translations.pl

On Thu, Jan 1, 2015 at 4:10 PM, Karsten Hohmeier
<karsten.hohmeier@tu-ilmenau.de> wrote:
> Hi Dennis,
>
>> What is the best way to parse this information in a reliable way?
>
> Maybe you could try dumping the table in XML as mentioned by the manpage?
>
> conntrack -L -o xml
>     Dump the connection tracking table in XML
>
> Best Regards
>
> Karsten
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Parsing conntrack entries
  2015-01-01 22:14 Parsing conntrack entries Dennis Jacobfeuerborn
  2015-01-02  0:10 ` Karsten Hohmeier
@ 2015-01-03  7:51 ` Hendrik Visage
  1 sibling, 0 replies; 4+ messages in thread
From: Hendrik Visage @ 2015-01-03  7:51 UTC (permalink / raw)
  To: Dennis Jacobfeuerborn; +Cc: netfilter

On Fri, Jan 2, 2015 at 12:14 AM, Dennis Jacobfeuerborn
<dennisml@conversis.de> wrote:
> Hi,
> I'm trying to write a small python script that creates some statistics
> from the current conntrack entries of a system. The problem I've run
> into is that I cannot find a good description of the output format of
> the conntrack tool and while I initially though the format is reasonably
> straightforward to deduce I ran into some snags.
>
> The format of a line not only changes with protocol and entry state but
> even entries with the same protocol and state seem to have different
> formats:
>
> tcp      6 3 CLOSE src=<IP1> dst=<IP2> sport=X dport=Y src=<IP2>
> dst=<IP1> sport=Y dport=X mark=0 use=1
>
> vs
>
> tcp      6 3 CLOSE src=<IP1> dst=<IP2> sport=X dport=Y src=<IP2>
> dst=<IP1> sport=Y dport=X [ASSURED] mark=0 use=1
>
> Why does one entry contain the [ASSURED] but the other does not?
>
> Also for some connections I see the [ASSURED] near the end of the line
> but for others I see an [UNREPLIED] in the *middle* of the line and no
> flag near the end of the line.

You have had a look at conntrack -E's output to see those transitions
happening in the [UPDATES]s?

>
> What is the meaning of the "use" field?
>
> What is the best way to parse this information in a reliable way?
>
> Regards,
>   Dennis
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-03  7:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01 22:14 Parsing conntrack entries Dennis Jacobfeuerborn
2015-01-02  0:10 ` Karsten Hohmeier
2015-01-02  0:26   ` Stig Thormodsrud
2015-01-03  7:51 ` Hendrik Visage

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.