LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-06-2013, 11:30 PM   #1
systemlordanubis
Member
 
Registered: Jun 2010
Distribution: Debian, Ubuntu, Win
Posts: 143

Rep: Reputation: 16
Creating a custom iptables target module based on LOG.


Hi All,

I'm currently using the 'LOG' target of iptables to send information into the syslog which another program then reads (tail -f) to collect the MAC and IP of particular packets of interest.

What I'm wanting to do is short-cut this step of going into syslog as it's not necessary.

What I want to be able to do is create my own version of the 'LOG' target that will send the MAC and IP of the packets that match the rule to a custom process (or more likely a socket) on the machine.

I've had a read through this site http://pudhumaijude.blogspot.com/201...-iptables.html and this PDF http://inai.de/documents/Netfilter_Modules.pdf but unfortunately the part I can't work out is where the actual 'logging' takes place.

Is there someone out there who might be able to point me in the right direction?

Thanks
Anubis.
 
Old 10-08-2013, 02:39 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by systemlordanubis View Post
I'm currently using the 'LOG' target of iptables to send information into the syslog which another program then reads (tail -f) to collect the MAC and IP of particular packets of interest. What I'm wanting to do is short-cut this step of going into syslog as it's not necessary.
It's not that syslog is not necessary but the mechanism is that these messages enter the kernel message ring buffer by default and where they exit is determined by which facility is set ('man 3 syslog') when using --log-level in -j LOG in combination with the facility and destination configured in (r)syslog.conf. Depending on what processing is needed (do clarify?) and depending on what syslog daemon you use you could already have part of it solved. For example Rsyslog allows you to run an(y) external command on message reception (no idea what the execution penalty / overhead would be though).


Quote:
Originally Posted by systemlordanubis View Post
What I want to be able to do is create my own version of the 'LOG' target that will send the MAC and IP of the packets that match the rule to a custom process (or more likely a socket) on the machine.
I really wonder if you would require invasive modification of Netfilter code when there's ready-made ULOGD and NFQUEUE? For example ULOGD-related specter does seem to do exec too or see nfqueue-bindings examples with respect to Scapy.
 
Old 10-08-2013, 11:24 PM   #3
systemlordanubis
Member
 
Registered: Jun 2010
Distribution: Debian, Ubuntu, Win
Posts: 143

Original Poster
Rep: Reputation: 16
Hi unSpawn,

Thanks very much for your reply. I had always wondered about the 'LOG' target as to how it ends up in the syslog, but your explanation clears that up nicely.

The ULOGD seems like it might do the job; wonder why I'd not come across it before. Anyway, I'll check over that before 'invading' modifications to netfilter.

Thanks
Anubis.
 
  


Reply



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
Creating Custom LiveOS ISO with Custom Files and RPMs niteshadw Red Hat 1 11-06-2012 10:44 AM
iptables creating malformed log messages katachihcatak Linux - Software 4 10-23-2011 10:42 PM
iptables give error when LOG is the target warrior1 Linux - Software 3 08-10-2009 08:25 AM
Custom log file using iptables bobbera Linux - Server 0 03-17-2009 10:40 AM
Debian 3.0/r1 iptables LOG target not working markus1982 Linux - Distributions 5 05-25-2003 05:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:24 PM.

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