All of lore.kernel.org
 help / color / mirror / Atom feed
* How to log NAT translations
@ 2010-09-14 17:24 Italo Valcy
  2010-09-14 17:54 ` Jan Engelhardt
  0 siblings, 1 reply; 6+ messages in thread
From: Italo Valcy @ 2010-09-14 17:24 UTC (permalink / raw)
  To: netfilter

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi guys!

I'm a newbie in this mainling list, so I'm sorry if this question was
already asked.

I'd like to have more specific logging output of NAT translation in
iptables. Is there an way to logging of ORIGINAL_IP/ORIGINAL_PORT +
TRANSLATED_IP/TRANSLATED_PORT?

I know that I can put a logging rule before my NAT rule, but this way
I haven't the TRANS_IP/TRANS_PORT... for instance:

iptables -t nat -I POSTROUTING -s 10.0.0.0/24 -j SNAT --to 172.16.0.1
iptables -t nat -I POSTROUTING -s 10.0.0.0/24 -j LOG

In the above example I don't know how to get the TRANS_PORT...

I also know that we can access this information through
/proc/net/ip_conntrack (or using netstat-nat), but to get all
translation of a whole day its a big overhead to parse that file all
the time...

Thanks for any help!

- -- 
Saudações,

Italo Valcy :: http://wiki.dcc.ufba.br/~ItaloValcy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyPr98ACgkQfidLqjN6RNGWAgCgjLgYUkPiAEp+C2znpRqUskoU
FAQAoIeWZQEXFS9LY2RSnxlSKjrmtkNL
=WLWD
-----END PGP SIGNATURE-----


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

* Re: How to log NAT translations
  2010-09-14 17:24 How to log NAT translations Italo Valcy
@ 2010-09-14 17:54 ` Jan Engelhardt
  2010-09-21  2:25   ` Italo Valcy
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Engelhardt @ 2010-09-14 17:54 UTC (permalink / raw)
  To: Italo Valcy; +Cc: netfilter

On Tuesday 2010-09-14 19:24, Italo Valcy wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hi guys!
>
>I'm a newbie in this mainling list, so I'm sorry if this question was
>already asked.
>
>I'd like to have more specific logging output of NAT translation in
>iptables. Is there an way to logging of ORIGINAL_IP/ORIGINAL_PORT +
>TRANSLATED_IP/TRANSLATED_PORT?

conntrack -E

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

* Re: How to log NAT translations
  2010-09-14 17:54 ` Jan Engelhardt
@ 2010-09-21  2:25   ` Italo Valcy
  2010-09-21  9:26     ` Jan Engelhardt
  0 siblings, 1 reply; 6+ messages in thread
From: Italo Valcy @ 2010-09-21  2:25 UTC (permalink / raw)
  To: jengelh; +Cc: netfilter

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jan,

Em 14-09-2010 14:54, Jan Engelhardt escreveu:
> On Tuesday 2010-09-14 19:24, Italo Valcy wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi guys!
>>
>> I'm a newbie in this mainling list, so I'm sorry if this question was
>> already asked.
>>
>> I'd like to have more specific logging output of NAT translation in
>> iptables. Is there an way to logging of ORIGINAL_IP/ORIGINAL_PORT +
>> TRANSLATED_IP/TRANSLATED_PORT?
> 
> conntrack -E

Thank you for the reply.

Actually, I wanna something more simple and specific than the command
above. Using 'conntrack -E', I still have to parse the package events
NEW, UPDATE and DESTROY if I wanna know the  of a NAT, for example.
Furthermore, with 'conntrack -E', in my opinion, we have an important
overhead of the output (it's so many messages to write to stdout - or
even redirect to a file)...

My ideia is to write a NAT (or conntrack) helper (as a kernel module)
that monitors the DESTROY event of a DNAT and try to find out when was
the NEW event of the same connection (maybe we have this information in
some struct..); then we write a log message (like LOG target does) which
contains ip_src-orig/port_src-orig,
ip_src-translated/port_src-translated, ip_dst/port_dst, duration of the
NAT (a little bit similar to Cisco/Asa NAT logging..). What do you
think? Where can I find some documentation to read?

Thank you so much for any help!


- -- 
Saudações,

Italo Valcy :: http://wiki.dcc.ufba.br/~ItaloValcy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyYF4kACgkQfidLqjN6RNGBrgCdGeGdZe4jzY7cR9xM5zNqV/RJ
k20AnRl6VKzz31k2vSqgQmL5Tafm931s
=bUcw
-----END PGP SIGNATURE-----

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

* Re: How to log NAT translations
  2010-09-21  2:25   ` Italo Valcy
@ 2010-09-21  9:26     ` Jan Engelhardt
  2010-09-21  9:45       ` Pablo Neira Ayuso
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Engelhardt @ 2010-09-21  9:26 UTC (permalink / raw)
  To: Italo Valcy; +Cc: netfilter

On Tuesday 2010-09-21 04:25, Italo Valcy wrote:

>Actually, I wanna something more simple and specific than the command
>above. Using 'conntrack -E', I still have to parse the package events
>NEW, UPDATE and DESTROY if I wanna know the  of a NAT

So use `conntrack -Ee NEW` to limit the output :)
If that is still too much overhead, I'm sure you can directly use
libnetfilter_conntrack's library interface to get at these events.

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

* Re: How to log NAT translations
  2010-09-21  9:26     ` Jan Engelhardt
@ 2010-09-21  9:45       ` Pablo Neira Ayuso
  2010-09-21 10:22         ` Jozsef Kadlecsik
  0 siblings, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2010-09-21  9:45 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Italo Valcy, netfilter

On 21/09/10 11:26, Jan Engelhardt wrote:
> On Tuesday 2010-09-21 04:25, Italo Valcy wrote:
> 
>> Actually, I wanna something more simple and specific than the command
>> above. Using 'conntrack -E', I still have to parse the package events
>> NEW, UPDATE and DESTROY if I wanna know the  of a NAT
> 
> So use `conntrack -Ee NEW` to limit the output :)
> If that is still too much overhead, I'm sure you can directly use
> libnetfilter_conntrack's library interface to get at these events.

You can refine this a bit more with:

`conntrack -Ee NEW --any-nat'

It was introduced in conntrack-tools-0.9.15.

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

* Re: How to log NAT translations
  2010-09-21  9:45       ` Pablo Neira Ayuso
@ 2010-09-21 10:22         ` Jozsef Kadlecsik
  0 siblings, 0 replies; 6+ messages in thread
From: Jozsef Kadlecsik @ 2010-09-21 10:22 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Jan Engelhardt, Italo Valcy, netfilter

On Tue, 21 Sep 2010, Pablo Neira Ayuso wrote:

> On 21/09/10 11:26, Jan Engelhardt wrote:
> > On Tuesday 2010-09-21 04:25, Italo Valcy wrote:
> > 
> >> Actually, I wanna something more simple and specific than the command
> >> above. Using 'conntrack -E', I still have to parse the package events
> >> NEW, UPDATE and DESTROY if I wanna know the  of a NAT
> > 
> > So use `conntrack -Ee NEW` to limit the output :)
> > If that is still too much overhead, I'm sure you can directly use
> > libnetfilter_conntrack's library interface to get at these events.
> 
> You can refine this a bit more with:
> 
> `conntrack -Ee NEW --any-nat'

Yes, but it's strange to use 'conntrack' for logging. Isn't it simpler to 
use ulogd2 and the ulogd_inpflow plugin?

Best regards,
Jozsef
-
E-mail  : kadlec@blackhole.kfki.hu, kadlec@mail.kfki.hu
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
          H-1525 Budapest 114, POB. 49, Hungary

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

end of thread, other threads:[~2010-09-21 10:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14 17:24 How to log NAT translations Italo Valcy
2010-09-14 17:54 ` Jan Engelhardt
2010-09-21  2:25   ` Italo Valcy
2010-09-21  9:26     ` Jan Engelhardt
2010-09-21  9:45       ` Pablo Neira Ayuso
2010-09-21 10:22         ` Jozsef Kadlecsik

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.