Skip to contentSkip to conversation

A Simple Question

DISCUSSION Robb Bossley 4 participants 4 messages Aug 10, 2005 – Aug 12, 2005

lore
Share & tools
lore
#0 lore raw

I have been using Linux for quite some time, and I really enjoy the power that is available with netfilter. Thank you for all of your input into the development and testing of it.

I have used other people's scripts to configure my firewall for a number of years, though I usually rolled my own kernels for this.

I have been reading the mailing list posts and it seems that most of you who are very knowledgeable with netfilter would propose a default policy of DROP on both the INPUT and FORWARD chains.

iptables -P INPUT DROP
iptables -P FORWARD DROP

However, I have noticed that a number of what I would consider to be strong contenders in the market use default policies of ACCEPT and then have a DROP rule at the end of the tables / chain.

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT ...................................(other stuff here).......................... iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP

I'm confused. Which is preferred for security and why? (Or is this just six of one, half a dozen of another?)

Signature · 3 lines
As if you could kill time without injuring eternity.  The mass of men
live lives of quiet desperation.
- Henry David Thoreau
#1 lore raw
Quoted 6 lines · Robb Bossley

I have been reading the mailing list posts and it seems that most of you who are very knowledgeable with netfilter would propose a default policy of DROP on both the INPUT and FORWARD chains.

iptables -P INPUT DROP
iptables -P FORWARD DROP

Yes, but ...

Quoted 9 lines

However, I have noticed that a number of what I would consider to be strong contenders in the market use default policies of ACCEPT and then have a DROP rule at the end of the tables / chain.

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT ...................................(other stuff here).......................... iptables -A INPUT -j DROP iptables -A FORWARD -j DROP

... this is simply another means to the same end.

Quoted 2 lines

I'm confused. Which is preferred for security and why? (Or is this just six of one, half a dozen of another?)

It all depends on the "other stuff" in the middle. At my most complex site, I went for default ACCEPT policies because I had multiple types of internal interfaces. Even those have varying needs. It just seemed that an ACCEPT policy would be the simplest way to get the job done. Everything we don't want is dropped (or rejected), everything we do want is accepted.

Signature · 2 lines
    mail to this address is discarded unless "/dev/rob0"
    or "not-spam" is in Subject: header
#2 lore raw
In reply to Robb Bossley
Quoted 11 lines

iptables -P INPUT DROP
iptables -P FORWARD DROP
VS
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
...(other stuff here)...
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP

Which is preferred for security and why?

Both equally work well. It's just a matter from which side you tackle the problem. Compare with 3d-engine editing:

A Quake2 map starts with "air" and you got to add walls -
that's like -P ACCEPT and -j REJECT/DROP

An Unreal map starts with "everything filled" and you got to subtract rooms -
like -P DROP and -j ACCEPT

In fact, sometimes it is wise to alternate between the two methods within the same table. I've got this in some ruleset:

-P INPUT DROP
-p tcp -m multiport --dport someservices -j ACCEPT (denying all other traffic)

-P OUTPUT ACCEPT
-o $internal -j DROP
(allowing all other interfaces)

Just like Apache's "Order allow,deny" if you need another inspiration for comparison.

Jan Engelhardt

Signature · 1 line
| Alphagate Systems, http://alphagate.hopto.org/
#3 lore raw
In reply to Robb Bossley
Quoted 18 lines · Robb Bossley

I have been using Linux for quite some time, and I really enjoy the power that is available with netfilter. Thank you for all of your input into the development and testing of it.

I have used other people's scripts to configure my firewall for a number of years, though I usually rolled my own kernels for this.

I have been reading the mailing list posts and it seems that most of you who are very knowledgeable with netfilter would propose a default policy of DROP on both the INPUT and FORWARD chains.

iptables -P INPUT DROP
iptables -P FORWARD DROP

However, I have noticed that a number of what I would consider to be strong contenders in the market use default policies of ACCEPT and then have a DROP rule at the end of the tables / chain.

Quoted 8 lines

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT ...................................(other stuff here).......................... iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP

I'm confused. Which is preferred for security and why? (Or is this just six of one, half a dozen of another?)

IMHO both methods are just about equally as effective. However I believe that by using the default policy of a chain you can save adding a rule that must be traversed and thus make the processing just slightly faster. On the other hand you can only set default policies on built in chains and thus you must do your own ""policy equivalent at the end of user defined chains with the rules that you have noticed. Thus for uniformity it may just be easier for some firewall authors to stick with the method that they know will work in EVERY chain than to have to remember which chain they are in. To me this issue is really 5.5 of one dozen and 6.5 of another, close but not exactly the same.

Grant. . . .