Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-27-2006, 06:41 PM
|
#1
|
Member
Registered: Oct 2005
Location: Honolulu, Hawaii
Distribution: Fedora Core 1-7, CentOS 4/5, Ubuntu/Xubuntu
Posts: 63
Rep:
|
IPTABLES: How do you log denied packets
How do you log the deny & permitted packets when using IPTABLES? From time to time I need to write custom rules so being able to see what is being denied helps a lot.
My system runs CentOS4.3 & FC1-5. Thanks!
Wilson
|
|
|
08-27-2006, 07:16 PM
|
#2
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
You will need to adjust these to your system and place them at the bottom of the script after your allow rules, some custom logging rules will look like this:
Code:
iptables -A INPUT -p tcp -j LOG --log-prefix "TCP LOGDROP: "
iptables -A INPUT -p udp -j LOG --log-prefix "UDP LOGDROP: "
iptables -A INPUT -p icmp -j LOG --log-prefix "ICMP LOGDROP: "
iptables -A INPUT -f -j LOG --log-prefix "FRAGMENT LOGDROP: "
iptables -A INPUT -j DROP # make sure anything is drop after logging
These are pretty generic you may need to read up on iptables to find out how to use these rules properly
Last edited by fotoguy; 08-27-2006 at 07:18 PM.
|
|
|
08-27-2006, 09:32 PM
|
#3
|
Member
Registered: Oct 2005
Location: Honolulu, Hawaii
Distribution: Fedora Core 1-7, CentOS 4/5, Ubuntu/Xubuntu
Posts: 63
Original Poster
Rep:
|
Thanks! Does this automatically put the logs in /var/log/messages?
|
|
|
08-27-2006, 11:46 PM
|
#4
|
Senior Member
Registered: Mar 2003
Location: Brisbane Queensland Australia
Distribution: Custom Debian Live ISO's
Posts: 1,291
Rep:
|
Yes it should send all logs to /var/log/messages. Then if you want to view them you could make a cron job, or just run a script to find the logged packets and copy them to another file for easier viewing, or emailing to someone later.
Code:
#!/bin/sh
grep "TCP LOGDROP:" /var/log/messages >> /text/file/somewhere.txt
grep "UDP LOGDROP:" /var/log/messages >> /text/file/somewhere.txt
grep "ICMP LOGDROP:" /var/log/messages >> /text/file/somewhere.txt
grep "FRAGMENT LOGDROP:" /var/log/messages >> /text/file/somewhere.txt
exit 0
|
|
|
All times are GMT -5. The time now is 05:49 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|