LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-28-2013, 02:19 AM   #1
artaxerxe
LQ Newbie
 
Registered: Dec 2011
Posts: 21

Rep: Reputation: Disabled
Log restrictions on IPTABLES for ULOG extension


I built a server application that needs to implement a lawful interception system. (When I say lawful interception, I mean just simple logging of what user accessed). I opted for ULOG extension and write in a database the log results. My iptables' rule that did this is something like:

iptables -I POSTROUTING -m state --state NEW -o eth0 -s 10.0.0.0/24 -j ULOG --ulog-cprange 100 -t nat

From ULOG man pages I now that it has only four options that aren't related to log level: --ulog-nlgroup, --ulog-prefix, --ulog-cprange and --ulog-qthreshold. I would like to put some options on that rule so that some redundant data won't be logged in database anymore. Bellow I explain my issue:

In my table I have:

Code:
   user_ip | destination_ip | length   |protocol     | src_port |dst_port |
 10.3.1.10 | 173.194.70.149 |       60 |           6 |    38486 |         80 |  
 10.3.1.10 | 173.194.70.149 |       60 |           6 |    38487 |         80 | 
 10.3.1.10 | 173.194.70.149 |       60 |           6 |    38488 |         80 |
As you can see, the user_ip and destination_ip is the same in all three situations. Only the port from what the request is done differs. I put in my rule --state NEW option for avoiding to log many times the same thing. In above scenario it seems that the same connection is did on three different ports in the beginning. (Probably due to the TCP/IP, but in the case of UDP there are also other issues).

Question: Can anyone help me on eliminating that redundant data?

In the case of UDP protocol for example, there is no src_port, no dst_port specified, and the same tuple is logged for many times in the database. (Of course there are some other fields that differs like request time, but I didn't printed above for the sake of simplicity.) If you want an extract for UDP, just tell me.

I would like to eliminate the redundant data for the fact that there can be situations when this server can be used for thousands or ten thousands of users, and in this case, eliminating this redundant data would increase performance for different tasks.
 
Old 05-28-2013, 02:35 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if you don't care abuot the source port (which maybe you should...) then you can possibly work something out with the RECENT module

http://snowman.net/projects/ipt_recent/

here you'd say that if you have not seen that source to that destination port then jump to the logging target.
 
Old 05-28-2013, 02:39 AM   #3
artaxerxe
LQ Newbie
 
Registered: Dec 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by acid_kewpie View Post
if you don't care abuot the source port (which maybe you should...)
Yes, I care about it.
 
Old 05-28-2013, 04:00 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well if you care about it, you need to log it.
 
  


Reply

Tags
iptables, networking



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Iptables - unable to use target ULOG on Fed 17 Lantzvillian Linux - Networking 2 09-17-2012 05:44 PM
How to write two iptables ulog streams into separate files? adept Linux - Newbie 0 10-03-2011 07:06 PM
iptables - interfaces, ports restrictions owbr4dh02 Linux - Security 9 02-04-2007 05:46 PM
ULOG iptables Mysql gabsik Linux - Software 0 07-15-2006 09:24 AM
General gateway logging (and iptables ULOG) ? michaelsanford Linux - Networking 16 05-18-2005 08:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration