Skip to contentSkip to conversation

Chain Policy DROP versus ACCEPT and logging

DISCUSSION Ted Kaczmarek 3 participants 3 messages Oct 12, 2003

lore
Share & tools
lore
#0 lore raw

I have seen many setups where the default CHAIN Policy is to accept packets by default versus dropping them.
From my perspective a firewall should implicitly deny everything, hence INPUT and FORWARD should be DROP.
Then rules are put in to allow what you want.
But, one seems to lose some logging capabilities with such a setup. Is their a way to log the default INPUT and FORWARD policies for dropped packets with them set to DROP as opposed to having them set to ACCEPT and putting in logs for any deny rules.

Thanks,
Ted

#1 lore raw
Quoted 9 lines · Ted Kaczmarek

I have seen many setups where the default CHAIN Policy is to accept packets by default versus dropping them.

Quoted 1 line

From my perspective a firewall should implicitly deny everything, hence

INPUT and FORWARD should be DROP.
Then rules are put in to allow what you want.
But, one seems to lose some logging capabilities with such a setup. Is their a way to log the default INPUT and FORWARD policies for dropped packets with them set to DROP as opposed to having them set to ACCEPT and putting in logs for any deny rules.

Yep, just make a log rule last in the chain...

iptables -A FORWARD -j LOG --log-level 7 --log-prefix "FWDDROP:"

for instance. Just remember that any rules added after this cannot simply be "-A", or they'll be appended after the log rule. They'll still work properly but the packets they accept would be logged as having been dropped.

j

#2 lore raw
In reply to Ted Kaczmarek
Quoted 3 lines · Ted Kaczmarek

Is their a way to log the default INPUT and FORWARD policies for dropped packets with them set to DROP as opposed to having them set to ACCEPT and putting in logs for any deny rules.

Logging in Netfilter does not behave as it used to with ipchains. You cannot log and drop within the same rule. Suppose you want to log and drop all UDP traffic :

	iptables -A INPUT -p udp -j LOG --log-prefix "UDP dropped : "
	iptables -A INPUT -p udp -j DROP

LOG is a target (non terminating one).

This said, if you want to log packets that hit chain policy, then you have to put a logging rule at the very end of the chain :

iptables -A INPUT -j LOG "INPUT chain policy drop : "

And you're done.

Signature · 2 lines
http://www.netexit.com/~sid/
PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE