LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 05-02-2013, 01:05 AM   #1
singi21007
LQ Newbie
 
Registered: May 2013
Location: Chennai
Posts: 2

Rep: Reputation: Disabled
dropping ICMP fragments with iptables


I am trying to prevent my system from DoS attacks. The first thing i am trying to do is to prevent my system from fragmented ICMP packets.
To do the same i have installed the following rule:
iptables -A INPUT -p icmp -f -j DROP
With the above rule, i don't see anything happening. Still i am able to receive echo-responses for echo requests that i sent with size as 5000.
I saw the iptables statistics and i see the rule is not getting hit at all.
[root@myPc ~]# iptables -L -v -n
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP icmp -f * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Then i slightly modified the rule as :
iptables -A INPUT -p icmp ! -f -j DROP
With the above rule, all ICMP echo-requests(both fragmented and non-fragmented) are getting dropped. I am not able to ping at all.
[root@myPc ~]# iptables -L -v -n
Chain INPUT (policy ACCEPT 17 packets, 1132 bytes)
pkts bytes target prot opt in out source destination
4 10224 DROP icmp !f * * 0.0.0.0/0 0.0.0.0/0

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 9 packets, 798 bytes)
pkts bytes target prot opt in out source destination

For any ICMP packets, the drop counter is incremented by 1. Which means in case of fragmented packets only the first packet matches the rule and gets dropped.

Please help me in understanding the behavior.
 
Old 05-04-2013, 03:41 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Instead of using "-j DROP" try using a "-j LOG" rule first to "debug" what that rule would do. Easiest, quickest way to start debugging rule sets.
 
Old 05-06-2013, 09:37 AM   #3
singi21007
LQ Newbie
 
Registered: May 2013
Location: Chennai
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi unSpawn,

Thank you for your suggestion.
The main problem i face is my rule is not getting correctly match(pls see in the iptables statistics that i have mentioned).
As the rule is not getting matched, even if give log option is specified no entries is getting logged.

Regards,
Singi21007
 
Old 05-09-2013, 03:30 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
See if this matches anything:
Code:
iptables -A INPUT -f -j LOG --log-prefix "IN_frags "
iptables -A INPUT -f -j DROP
else try using the "connbytes" module (see 'iptables -m connbytes --help')?

*Do realize though a fragmentation attack doesn't necessarily require overly large packets: it can also be about many packets very small in size that only cause problems when reassembly starts. While the kernel and the Netfilter framework are very good at detecting, and at time correcting, anomalies an IDS like Snort may be of more help because of its IP defragmentation preprocessor.
 
  


Reply



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
Iptables Drop Icmp krlos07 Linux - Networking 2 05-09-2011 11:01 AM
[SOLVED] Iptables: icmp and fragmented icmp rule matching Cenobite Linux - Networking 2 02-03-2011 03:37 AM
IPTABLES question - how do you reject icmp? Thaidog Linux - Networking 12 12-06-2007 11:16 AM
dropping of ICMP packets from martian sources kishku Linux - Networking 2 10-19-2004 08:06 PM
iptables icmp limits dunkyb Linux - Security 0 05-08-2003 05:10 PM

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

All times are GMT -5. The time now is 06:16 AM.

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