Skip to contentSkip to conversation

Accept icmp-type destination-unreachable with limit

DISCUSSION Michael K 2 participants 3 messages Mar 28, 2003 – Apr 1, 2003

lore
Share & tools
lore

Michael K

author
#0 lore raw

Is this a good rule? According to
http://www.robertgraham.com/pubs/firewall-seen.html#8.1 It's a good thing to accept this icmp type 3 and 4. But now the firewall is open for dos attacks. So I thought I put a limit to the rule.

iptables -A INPUT -p ICMP --icmp-type destination-unreachable \
	-m limit --limit 10/minute --limit-burst 5 -j ACCEPT

iptables -A INPUT -p ICMP --icmp-type source-quench -j ACCEPT

If I had a personal firewall allowing some ports out and then allowing everything in that is established and related for all protocols. Then I don't need the icmp type 3 and 4 for the input, right? Something like this.

iptables -A OUTPUT -p TCP -m multiport --dports 20,21,25,53,80,110,443 -j ACCEPT
iptables -A OUTPUT -p UDP --dport 53 -j ACCEPT
iptables -A OUTPUT -p ICMP --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p UDP 33434:33523 -j ACCEPT
iptables -A INPUT -p ALL -m state --state RELATED,ESTABLISHED -j ACCEPT

Btw: Is this a good (and short) firewall allowing most common internet protocols and utilities? Any comments on above?

/Klintan

author
#1 lore raw
Quoted 33 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Michael K
Sent: Friday, March 28, 2003 10:19 PM
To: [email protected]
Subject: Accept icmp-type destination-unreachable with limit

Is this a good rule? According to
http://www.robertgraham.com/pubs/firewall-seen.html#8.1 It's a good thing to accept this icmp type 3 and 4. But now the firewall is open for
dos attacks. So I thought I put a limit to the rule.

iptables -A INPUT -p ICMP --icmp-type destination-unreachable \
	-m limit --limit 10/minute --limit-burst 5 -j ACCEPT

iptables -A INPUT -p ICMP --icmp-type source-quench -j ACCEPT

If I had a personal firewall allowing some ports out and then allowing everything in that is established and related for all protocols. Then I
don't need the icmp type 3 and 4 for the input, right? Something like this.

iptables -A OUTPUT -p TCP -m multiport --dports 20,21,25,53,80,110,443 -j ACCEPT
iptables -A OUTPUT -p UDP --dport 53 -j ACCEPT
iptables -A OUTPUT -p ICMP --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p UDP 33434:33523 -j ACCEPT
iptables -A INPUT -p ALL -m state --state RELATED,ESTABLISHED -j ACCEPT

Quoted 6 lines

Btw: Is this a good (and short) firewall allowing most common internet protocols and utilities? Any comments on above?

/Klintan

Is there no comments on this?

/Klintan

#2 lore raw
Quoted 9 lines · Michael K
Quoted 8 lines

Is this a good rule? According to
http://www.robertgraham.com/pubs/firewall-seen.html#8.1 It's a good thing to accept this icmp type 3 and 4. But now the firewall is open for
dos attacks. So I thought I put a limit to the rule.

iptables -A INPUT -p ICMP --icmp-type destination-unreachable \
	-m limit --limit 10/minute --limit-burst 5 -j ACCEPT

iptables -A INPUT -p ICMP --icmp-type source-quench -j ACCEPT

Is there no comments on this?

Just one.

When an ICMP error packet is received by your box, conntrack tries to associate it to an existing IP flow in conntrack table. If it does match something, it is RELATED ; if not, it's INVALID.

So, if you want to accept ICMP errors, just accept RELATED stuff. And that's what you do with your last rule :

Quoted 2 lines
Quoted 2 lines

iptables -A INPUT -p ALL -m state --state RELATED,ESTABLISHED -j ACCEPT

This means that even if a ICMP destination-unreachable breaks the limit you set, it will be accepted as long as it is flaged RELATED.

So, imho, you should first DROP all INVALID stuff at ruleset top. It's better get rid of them at first than wasting ressources in having them go through the whole chain and get dropped by policy. So, no INVALID. At this point, ICMP error packets you'll get into your next rules are RELATED, and so are not likely to be part of a DoS. If someone's try to DoS you via ICMP, most of packet's you'll receive will be INVALID, and will get dropped. So you're right in saying you do not need theses rules.

So, for Netfilter as a good conntrack engine, I would let it handle ICMP errors. Better focus on DoS that are based on ping, UDP, TCP SYN, or stuff.

Signature · 4 lines
Cédric Blancher  <[email protected]>
IT systems and networks security - Cartel Sécurité
Phone : +33 (0)1 44 06 97 87 - Fax: +33 (0)1 44 06 97 99
PGP KeyID:157E98EE  FingerPrint:FA62226DA9E72FA8AECAA240008B480E157E98EE