LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-01-2005, 02:06 AM   #1
alizard
Member
 
Registered: Jan 2003
Posts: 56

Rep: Reputation: 15
how do I enable logging in iptables for FC2?


I know it's running (two different config programs show the firewall enabled, iptables -L -v returns a ruleset and an external firewall test says I'm running in full stealth mode), but I can't recover a log via fwlogwatch,

[root@terrarium root]# fwlogwatch
fwlogwatch summary
Generated Tuesday March 01 00:03:50 PST 2005 by root.
0 of 10031 entries in the file "/var/log/messages" are packet logs, 0 have unique characteristics.
No valid time entries found.
All entries were logged by the same host: "".
All entries are from the same chain: "".
All entries have the same target: "".
All entries are from the same interface: "".

which tells me that:
1) the log is somewhere other than /var/log/messages
or
2) the thing *isn't keeping* a log.

Can anyone give me a clue?

thanks
 
Old 03-01-2005, 09:11 AM   #2
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Rep: Reputation: 30
Re: how do I enable logging in iptables for FC2?

Quote:
Originally posted by alizard
1) the log is somewhere other than /var/log/messages
or
2) the thing *isn't keeping* a log.
You are correct. Even if you are logging the violations somewhere else (check your /etc/syslog.conf file for "kern.=warn" settings), the violations would likely still showup in /var/log/messages b/c that's wehre everything shows up. So now we look at #2. Do the following:
Code:
# iptables -nL
and look for rules with a target of LOG. Should like something like the following:
Code:
LOG        udp  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 4 prefix `UNKNOWN UDP OUT: '
DROP       udp  --  0.0.0.0/0            0.0.0.0/0
LOG        tcp  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 4 prefix `UNKNOWN TCP OUT: '
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0
LOG        icmp --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 4 prefix `UNKNOWN ICMP OUT: '
DROP       icmp --  0.0.0.0/0            0.0.0.0/0
If you don't see any rules with a target of LOG, you aren't logging anything.
 
Old 03-01-2005, 08:54 PM   #3
alizard
Member
 
Registered: Jan 2003
Posts: 56

Original Poster
Rep: Reputation: 15
Re: Re: how do I enable logging in iptables for FC2?

Quote:
Originally posted by TruckStuff
You are correct. Even if you are logging the violations somewhere else (check your /etc/syslog.conf file for "kern.=warn" settings), the violations would likely still showup in /var/log/messages b/c that's wehre everything shows up. So now we look at #2. Do the following:
Code:
# iptables -nL
and look for rules with a target of LOG. Should like something like the following:
Code:
LOG        udp  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 4 prefix `UNKNOWN UDP OUT: '
DROP       udp  --  0.0.0.0/0            0.0.0.0/0
LOG        tcp  --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 4 prefix `UNKNOWN TCP OUT: '
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0
LOG        icmp --  0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 4 prefix `UNKNOWN ICMP OUT: '
DROP       icmp --  0.0.0.0/0            0.0.0.0/0
If you don't see any rules with a target of LOG, you aren't logging anything.
================================
So adding these rules to the right .conf file should get me logging? Thanks, I'll give it a try.
 
Old 03-02-2005, 08:49 PM   #4
alizard
Member
 
Registered: Jan 2003
Posts: 56

Original Poster
Rep: Reputation: 15
Re: Re: Re: how do I enable logging in iptables for FC2?

Quote:
Originally posted by alizard
================================
So adding these rules to the right .conf file should get me logging? Thanks, I'll give it a try.
Where can I find a good set of rules to turn logging on? Will the sample you posted work? Should this go at the end of the config file? Is there anything else I need to know?

thanks
 
Old 03-03-2005, 10:40 AM   #5
Kerberus
LQ Newbie
 
Registered: Mar 2005
Posts: 10

Rep: Reputation: 0
To much info can be counter productive so decided on what to log, for example do you really need to logs every packet going through your system, probably not.
If your paranoid and want to logs the first connection for each new access then just log the first SYN flag request for a handshake, also set a limit, if someone knows your logging you can flood the box causing the mount to full up. That leads me to the next thing, move your logs files to a partition that has a fixed amount of space with house cleaning, so every 7 days or so the logs are removed or compressed etc.

If I was you I would log the following: “yes I’m paranoid”

New connections.
Dropped connections that failed the stateful inspection.
ICMP types 8, 11, 13
Any connections that are invalid due to managed flags.

Here’s some examples of this in IPtables.

iptables -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG --log-level info --log-prefix “**Invalid flags 1**"
iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j LOG --log-level info --log-prefix “**Invalid flags 2**"
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j LOG --log-level info --log-prefix “**Invalid flags 3**"
iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j LOG --log-level info --log-prefix “**Invalid flags 4**"
iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG --log-level info --log-prefix “**Invalid flags 5**"
# use your internet interface
iptables -A INPUT -i eth0 -p tcp ! --syn -m state --state NEW -m limit --limit 1/s --limit-burst 5 -j LOG --log-level info --log-prefix “**No SYN flag**“
iptables -A INPUT -i eth0 -p tcp --syn -m state --state NEW -m limit --limit 1/s --limit-burst 5 -j LOG --log-level info --log-prefix “**New Connection recorded**“
iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.0/16 -j LOG --log-level info --log-prefix “**Invalid IP on Interface**”
iptables -t nat -A PREROUTING -i eth0 -s 10.0.0.0/8 -j LOG --log-level info --log-prefix “**Invalid IP on Interface**”
iptables -t nat -A PREROUTING -i eth0 -s 172.16.0.0/12 -j LOG --log-level info --log-prefix “**Invalid IP on Interface**”
iptables -A INPUT -i eth0 -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 1 -j LOG --log-level info --log-prefix “**ping request**“

put your loggin in before you drop the packets or you don't log them as they are not passed down the chain in the preprocessing.

Kerberus
 
Old 03-06-2005, 05:18 AM   #6
alizard
Member
 
Registered: Jan 2003
Posts: 56

Original Poster
Rep: Reputation: 15
thanks...

this looks like exactly what I need. I'll figure out how to handle the log size problem later.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Howto to enable logging in Knoppix 3.8? bigrigdriver Linux - Software 5 10-05-2005 09:38 PM
howto enable logging from BIND 9 on Debian Sarge ? cccc Debian 2 07-07-2005 06:43 PM
Do you enable full sendmail logging? hbt Linux - Software 1 12-19-2004 03:06 PM
'whiteglass' how to enable in FC2? blackphiber Linux - General 0 05-25-2004 06:48 PM
Problem logging out of FC2 jwb Fedora 1 05-25-2004 11:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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