LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-09-2009, 11:27 AM   #1
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Rep: Reputation: 15
log everything except few


Hi,

I wanted to log all traffic which are going out from my server , except for some ports...

I tried with the following rule

iptables -I OUTPUT -p tcp --dport ! 80 -j LOG
iptables -I OUTPUT -p tcp --dport ! 25 -j LOG

But it is not working as expected, because, first rule logs packet destined to port 25 and second rule logs packet destined to port 80. I don't want to log packets destined to port 80 and 25. I want to however log rest packest.

How do I do that ?
 
Old 12-09-2009, 11:37 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can try the multiport match extension to specify a comma separated list of multiple ports (max 15), e.g.
Code:
iptables -I OUTPUT -m multiport -p tcp --dport !25,80 -j LOG
 
Old 12-09-2009, 11:58 AM   #3
sang_froid
Member
 
Registered: Oct 2006
Posts: 179

Original Poster
Rep: Reputation: 15
I already had tried it... IT doesn't work.


Quote:
Originally Posted by colucix View Post
You can try the multiport match extension to specify a comma separated list of multiple ports (max 15), e.g.
Code:
iptables -I OUTPUT -m multiport -p tcp --dport !25,80 -j LOG
 
Old 12-09-2009, 05:32 PM   #4
beadyallen
Member
 
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209

Rep: Reputation: 36
One way to do it would be to create a specific LOG chain. For example:
Code:
iptables -N LOGCHAIN
iptables -A LOGCHAIN -p tcp --dport 25 -j RETURN
iptables -A LOGCHAIN -p tcp --dport 80 -j RETURN
iptables -A LOGCHAIN -p tcp -j LOG
iptables -A LOGCHAIN -j RETURN #This is the default so not really needed
Then just jump to LOGCHAIN from the INPUT chain at a suitable point:
Code:
iptables -A INPUT -j LOGCHAIN
Hope that helps.
 
  


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
kernel log format in /var/log/kern.log sinu_nayak2001 Linux - Newbie 2 10-07-2009 08:34 AM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 04:14 PM
What the %$#@ is pam_unix (cron:session) doing every ten minutes? (/var/log/auth.log) CoffeeKing!!! Linux - Security 3 02-05-2009 07:07 AM
Can Samhain log my entries in /var/log/secure and /var/log/mesage to a central server abefroman Linux - Software 2 04-13-2008 04:13 PM
Opennms Logs - where are web.log, web_rtc.log and webauth.log referenced? not_much_of_a_guru Linux - Networking 0 07-12-2006 10:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:45 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