Ubuntu iptables logs not going to any log file
I am trying to put logs in iptables but I can not find any log in any file. Although when I run dmesg command, I can see the iptables entries. But the same entry doesn't go to any log file. Here is my iptables rule :
/sbin/iptables -I INPUT 1 -p tcp -j LOG --log-level info --log-prefix " [ IPTABLES " --log-uid
Here is the syslog.conf file :
# /etc/syslog.conf Configuration file for syslogd.
#
# For more information see syslog.conf(5)
# manpage.
#
# First some standard logfiles. Log by facility.
#
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv.none -/var/log/syslog
#cron.* -/var/log/cron.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
#
# Logging for the mail system. Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info -/var/log/mail.info
mail.warn -/var/log/mail.warn
mail.err -/var/log/mail.err
# Logging for INN news system
#
news.crit -/var/log/news/news.crit
news.err -/var/log/news/news.err
news.notice -/var/log/news/news.notice
#
# Some `catch-all' logfiles.
#
*.=debug;\
auth,authpriv.none;\
news.none;mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail,news.none -/var/log/messages
#
# Emergencies are sent to everybody logged in.
#
*.emerg *
#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
# news.=crit;news.=err;news.=notice;\
# *.=debug;*.=info;\
# *.=notice;*.=warn /dev/tty8
# The named pipe /dev/xconsole is for the `xconsole' utility. To use it,
# you must invoke `xconsole' with the `-file' option:
#
# $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
# busy site..
#
daemon.*;mail.*;\
news.err;\
*.=debug;*.=info;\
*.=notice;*.=warn -/var/log/xconsole.log
Here are some more details :
root@us4839:~# ps ax | grep syslog
11336 pts/1 S+ 0:00 grep syslog
17910 ? Ss 0:00 /sbin/syslogd
root@us4839:~#
root@us4839:~#
root@us4839:~# lsof /var/log/syslog
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
syslogd 17910 root 2w REG 0,42 5508 57114744 /var/log/syslog
root@us4839:~#
Am I doing anything wrong in this rule or there is something wrong somewhere else ?
Solution 1:
I've had a similar problem a long time ago and it is (in part) related to the OpenVZ architecture.
Can you please confirm that:
- the iptables rule syntax is correct
- syslog & klogd are running (as far as I can remember klogd is required for openVZ to log kernel messages properly)
Does dmesg output contain the iptables log lines? If yes, then this is likely a syslog config issue. You could try to add a directive that's placing kernel.warn in a separate iptables.log file.
Edit Did you check the logfiles manually? If yes I'd grep for it e.g. with
grep -rl "MAC" /var/log/* # should match, else use the interface name or IPTABLES as pattern
just to make sure...