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 01-05-2005, 04:32 AM   #1
Mischa
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Rep: Reputation: 0
Unhappy Logging iptables rules


I want to log my iptables rules to a seperate file.

In a iptables manual I found the following
Quote:
In other words, setting kern.=info /var/log/iptables in your syslog.conf file and then letting all your LOG messages in iptables use log level info, would make all messages appear in the /var/log/iptables file.
After doing this, I created the following rule:
iptables -I FORWARD -p TCP -d any/0 --dport 80 -j LOG --log-level info --log-prefix "TEST "

Now all my traffic going to websites should be logged in /var/log/iptables, but there is no such file!
Even restarting the network or creating the file by hand didn't solve my problem.

Anyone?
 
Old 01-05-2005, 06:36 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Edit your /etc/syslog.conf and look for the info log line, mine is :

# Log anything 'info' or higher, but lower than 'warn'.
# Exclude authpriv, cron, mail, and news. These are logged elsewhere.
*.info;*.!warn;\
authpriv.none;cron.none;mail.none;news.none -/var/log/messages

So add iptables to the exclude list :
*.info;*.!warn;\
authpriv.none;cron.none;mail.none;news.none;iptables.none -/var/log/messages

And add an entry for iptables on another line :
iptables.* -/var/log/iptables
 
Old 01-05-2005, 09:38 AM   #3
Mischa
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Thumbs down

Thanks for the tip;

Nothing is being logged into the files. Also the messages file doesn't contain logs of iptables

Killing and restarting syslogd didn't solve my problem either...
 
Old 01-05-2005, 02:20 PM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
less /usr/include/sys/syslog.h
...
...
#define LOG_INFO 6 /* informational */
...

So :
iptables -I FORWARD -p TCP -d any/0 --dport 80 -j LOG --log-level=6 --log-prefix "TEST

cat /etc/syslog.conf
...
...
kern.=info -/var/log/iptables
...

Last edited by Cedrik; 01-05-2005 at 02:29 PM.
 
  


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
IPTABLES - rules in /etc/sysconfig/iptables The_JinJ Linux - Newbie 6 11-20-2004 01:40 AM
iptables rules Hegemon Linux - Networking 0 01-28-2004 02:20 AM
iptables rules chrisfirestar Linux - Security 2 10-29-2003 02:30 AM
iptables rules Darin Linux - Security 1 01-23-2003 04:32 PM
iptables rules hazza96 Linux - Security 3 09-09-2001 11:16 AM

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

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