Skip to contentSkip to conversation

How to log

DISCUSSION Michael K 2 participants 3 messages Feb 25, 2003

lore
Share & tools
lore

Michael K

author
#0 lore raw

When I uses the --jump LOG in iptables it logs to /dev/console. Read the man page for syslog.conf(5) and added "kern.warn /var/log/krnmsg". Restarted syslog; and still it logs to /dev/console.
Can I prevent this from happening?
Is there another (better) way to log?
Can't I use something like "iptables.* /var/log/iptables" so that I only get messages from iptables? (Did try it, byt didn't work)

BTW: the system is Redhat 7.3

#1 lore raw
Quoted 3 lines · Michael K

When I uses the --jump LOG in iptables it logs to /dev/console. Read the man page for syslog.conf(5) and added "kern.warn /var/log/krnmsg". Restarted syslog; and still it logs to /dev/console.

You need to use "kern.=warn" to designate a target for kernel warning messages. You also, IIRC, need to make sure you don't have a kern.* entry before it, or a *.warn.

Quoted 1 line

Can I prevent this from happening?

Possibly. Check if you have a "kern.*" or any other entry going to "/dev/console", and if you do you can comment it out.

Quoted 1 line

Is there another (better) way to log?

You can use the ULOG target, but you'll need to install a few userspace programs to deal with that. If all you want is to look through logs occasionally for anything unexpected, or use the log to debug firewall rules as you work, follow the suggestion below.

Quoted 2 lines

Can't I use something like "iptables.* /var/log/iptables" so that I only get messages from iptables? (Did try it, byt didn't work)

You can get close to this on most systems. With most stable-kernel installations you have very few entries in the kernel debug stream, so you can add the parameter "--log-level 7" to you LOG rules, and divert "kern.=debug" in your syslog.conf file to an (almost) iptables-only log. If you also use the "--log-prefix" parameter you can prepend a specified string to each log entry from that rule, to help in reading the log. A useful example of all this is:

iptables -A FORWARD -j LOG --log-level 7 --log-prefix "Unexpected Forward:"

As the last rule in the FORWARD chain. If you have "kern.=debug /var/log/iptables" in syslog.conf then "cat /var/log/iptables | grep Unexp" would list out all the matching log entries.

Quoted 1 line

BTW: the system is Redhat 7.3

j

author
#2 lore raw
Quoted 50 lines

-----Original Message-----
From: Joel Newkirk [mailto:[email protected]]
Sent: Tuesday, February 25, 2003 10:21 PM
To: Michael K; [email protected]
Subject: Re: How to log

Quoted 2 lines · Michael K

When I uses the --jump LOG in iptables it logs to /dev/console. Read the man page for syslog.conf(5) and added "kern.warn

/var/log/krnmsg".

Quoted 1 line

Restarted syslog; and still it logs to /dev/console.

You need to use "kern.=warn" to designate a target for kernel warning messages. You also, IIRC, need to make sure you don't have a kern.* entry before it, or a *.warn.

Quoted 1 line

Can I prevent this from happening?

Possibly. Check if you have a "kern.*" or any other entry going to "/dev/console", and if you do you can comment it out.

Quoted 1 line

Is there another (better) way to log?

You can use the ULOG target, but you'll need to install a few userspace
programs to deal with that. If all you want is to look through logs occasionally for anything unexpected, or use the log to debug firewall
rules as you work, follow the suggestion below.

Quoted 2 lines

Can't I use something like "iptables.* /var/log/iptables" so that I only get messages from iptables? (Did try it, byt didn't work)

You can get close to this on most systems. With most stable-kernel installations you have very few entries in the kernel debug stream, so
you can add the parameter "--log-level 7" to you LOG rules, and divert
"kern.=debug" in your syslog.conf file to an (almost) iptables-only log.
If you also use the "--log-prefix" parameter you can prepend a specified
string to each log entry from that rule, to help in reading the log. A
useful example of all this is:

iptables -A FORWARD -j LOG --log-level 7 --log-prefix "Unexpected Forward:"

Quoted 8 lines

As the last rule in the FORWARD chain. If you have "kern.=debug /var/log/iptables" in syslog.conf then "cat /var/log/iptables | grep Unexp" would list out all the matching log entries.

Quoted 1 line

BTW: the system is Redhat 7.3

j

Thank you for your great answer. I'll check it later when I am @ work.

Regards Michael