About nixCraft

Topics

How can I enable or setup log message in the iptables firewall?

Posted by Vivek Gite [Last updated: March 28, 2006]

Linux firewall, iptables has the capability to log network activity to the syslog system. This is very useful to detect problems as well as to generate reports of network activity. You can also use this to detect all intrusion detection or unwanted incoming/outgoing connections etc.

LOG module
To enable logging option you need to use LOG iptables/kernel module. It turn on kernel logging of matching packets. When this option is set for a rule, the Linux kernel will print some information on all matching packets (like most IP header fields) via the kernel log.

For example, drop all connection coming from hacker/cracker IP address 202.54.10.202 and log them to syslog:

iptables -A INPUT -s 202.54.10.202 -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix ‘** FW-DROP-HACKER **’

iptables -A INPUT -s 202.54.10.202 -j DROP

Firewall rules are checked in a sequential manner So first you logged message with first rule and second rule drops the connection.

Where,

# grep ‘** FW-DROP-HACKER **’ /var/log/message

LOG module supports other options, read man page of iptables for more information.

E-mail this to a friend      Printable version

You may also be interested in other helpful articles:

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.