LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-01-2011, 08:37 AM   #1
Cenobite
LQ Newbie
 
Registered: Dec 2003
Location: South Africa
Distribution: CentOS, Arch
Posts: 25

Rep: Reputation: 0
Question Iptables: icmp and fragmented icmp rule matching


I'm creating a firewall script which contains within it the following:

Code:
# limit pings
$IPT -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j ACCEPT
$IPT -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j LOG --log-prefix "PING-DROP: "
$IPT -A INPUT -p icmp -j DROP

# Drop all fragmented ICMP packets (usually malicious)
$IPT -A INPUT -p icmp --fragment -j LOG --log-prefix "PING-FRAG: "
$IPT -A INPUT -p icmp --fragment -j DROP
My question is: does the first "-j DROP" target cause the last two lines never to match?
 
Old 02-03-2011, 02:04 AM   #2
hogar.strashni
Member
 
Registered: Dec 2007
Distribution: cp6
Posts: 44

Rep: Reputation: 2
Quote:
My question is: does the first "-j DROP" target cause the last two lines never to match?
I'm quite sure it does.
When examining the packet, icmp criterion is satisfied by checking ip header, and all fragments have the indicator of the embbaded protocol set to icmp, thus satisfying the rule and being dropped before they reach to check for fragmentation. Nevertheless, last two lines are necessary, because of first two rules. To name it:
Quote:
# limit pings
$IPT -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j ACCEPT
$IPT -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j LOG --log-prefix "PING-DROP: "
because if last two rules didn't exist, part of fragmented icmp traffic matching quoted rules, would still pass.
What makes me having second thoughts, is that it is possible that after checking rules in one (I'll call it)"chapter", iptables jumps to next "chapter", and not out. In that case everything is just fine. If iptables jumps out, after a single rule matched, then you need to move last two rules above the "limit pings" chapter, so they could filter fragmented icmp traffic before it could be accepted by first two rules of "limit pings" chapter.

I hope you'll excuse by bad English. If it is confusing, I'll reassemble the answer, just say it
Greetings
 
Old 02-03-2011, 03:37 AM   #3
Cenobite
LQ Newbie
 
Registered: Dec 2003
Location: South Africa
Distribution: CentOS, Arch
Posts: 25

Original Poster
Rep: Reputation: 0
Your english is perfectly fine, thanks hogar!

What I ended up doing is to move the two fragment rules to the top, so a check for fragmentation is done and everything else (unfragmented ping) falls through to the next rules.

Thanks very much!
 
  


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
iptables icmp error replay messages adam_blackice Linux - Networking 2 03-15-2008 07:05 AM
IPTABLES question - how do you reject icmp? Thaidog Linux - Networking 12 12-06-2007 11:16 AM
iptables DROP icmp applied, still being pinged linuxistan Linux - Networking 3 10-18-2004 10:26 PM
ICMP traffic archives/writing ICMP traffic in a file maia_1 Programming 0 07-20-2004 03:43 AM
iptables icmp limits dunkyb Linux - Security 0 05-08-2003 05:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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