Skip to contentSkip to conversation

Setting a default policy does not work :(

DISCUSSION Michael Gale 5 participants 6 messages Dec 2, 2003 – Dec 3, 2003

lore
Share & tools
lore
#0 lore raw

Hello,

I have a firewall with multiple interfaces. When I try to set a default policy it does not work. I believe this is a problem with netfilter and multiple interfaces.

Example:

Inserting the following to the bottom of my firewall script:

### Causes all traffic to or from the box on either interface to be dropped regardless of all other rules.

iptables --policy INPUT DROP iptables --policy OUTPUT DROP iptables --policy FORWARD DROP

### Causes all traffic to or from the box on either interface to be dropped regardless of all other rules.

iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
itpables -A FORWARD -j DROP

### But when adding:

iptables -A INPUT -i $EXT_FACE -j DROP iptables -A INPUT -i $INT_FACE -j DROP iptables -A OUTPUT -o $EXT_FACE -j DROP iptables -A OUTPUT -o $INT_FACE -j DROP iptables -A FORWARD -i $EXT_FACE -j DROP iptables -A FORWARD -i $INT_FACE -j DROP

The firewall rules behave as they should only allow traffic that matches the rules and the default policy now is DROP based on the rules.

I believe the problem is caused by having multiple interfaces -- if you only have 1 interface then the default policy is applied to this interface. But if you have multiple networks cards any rule or policy that does not specify a network interface becomes a global rule .. as in (iptables -A INPUT -j DROP) and takes affect before any other rules that are based upon network interface.

So if you have these two rules in your firewall script:
iptables -A INPUT -i $EXT_FACE -j ACCEPT iptables -A INPUT -j DROP

Even though the first rule is to accept all traffic everything would be denied because the second rule becomes like a global policy since no interface is associated with it and it actually gets checked before the packet can make it to the second rule.

Signature · 3 lines
Michael Gale
Network Administrator
Utilitran Corporation
#1 lore raw
Quoted 6 lines · Michael Gale

Hello,

I have a firewall with multiple interfaces. When I try to set a default policy it does not work. I believe this is a problem with netfilter and multiple interfaces.

Example:

Quoted 8 lines

Inserting the following to the bottom of my firewall script:

### Causes all traffic to or from the box on either interface to be dropped regardless of all other rules.

iptables --policy INPUT DROP iptables --policy OUTPUT DROP iptables --policy FORWARD DROP

I use
iptables -P INPUT DROP
instead and it works fine for me.
iptables 1.2.7a, kernel 2.4.20, SuSE 8.2

Quoted 25 lines

### Causes all traffic to or from the box on either interface to be dropped regardless of all other rules.

iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
itpables -A FORWARD -j DROP

### But when adding:

iptables -A INPUT -i $EXT_FACE -j DROP iptables -A INPUT -i $INT_FACE -j DROP iptables -A OUTPUT -o $EXT_FACE -j DROP iptables -A OUTPUT -o $INT_FACE -j DROP iptables -A FORWARD -i $EXT_FACE -j DROP iptables -A FORWARD -i $INT_FACE -j DROP

The firewall rules behave as they should only allow traffic that matches the rules and the default policy now is DROP based on the rules.

I believe the problem is caused by having multiple interfaces -- if you only have 1 interface then the default policy is applied to this interface. But if you have multiple networks cards any rule or policy that does not specify a network interface becomes a global rule .. as in (iptables -A INPUT -j DROP) and takes affect before any other rules that are based upon network interface.

So if you have these two rules in your firewall script:
iptables -A INPUT -i $EXT_FACE -j ACCEPT iptables -A INPUT -j DROP

Even though the first rule is to accept all traffic everything would be denied because the second rule becomes like a global policy since no interface is associated with it and it actually gets checked before the packet can make it to the second rule.

Signature · 7 lines
--
Raymond Leach <[email protected]>
Network Support Specialist
http://www.knowledgefactory.co.za
"lynx -source http://www.rchq.co.za/raymondl.asc | gpg --import"
Key fingerprint = 7209 A695 9EE0 E971 A9AD  00EE 8757 EE47 F06F FB28
--
#2 lore raw
In reply to Michael Gale
Quoted 8 lines · Michael Gale

Inserting the following to the bottom of my firewall script:

### Causes all traffic to or from the box on either interface to be dropped regardless of all other rules.

iptables --policy INPUT DROP iptables --policy OUTPUT DROP iptables --policy FORWARD DROP

Try:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Works for me on multiple firewalls using multiple interfaces.

Quoted 10 lines

### But when adding:

iptables -A INPUT -i $EXT_FACE -j DROP iptables -A INPUT -i $INT_FACE -j DROP iptables -A OUTPUT -o $EXT_FACE -j DROP iptables -A OUTPUT -o $INT_FACE -j DROP iptables -A FORWARD -i $EXT_FACE -j DROP iptables -A FORWARD -i $INT_FACE -j DROP

The firewall rules behave as they should only allow traffic that matches the rules and the default policy now is DROP based on the rules.

Actually, this does not change the policy but would rather make the last rule in each chain a drop rule. If you moved these commands to the beginning of your script you would have the same problem as above. Using -P should fix your problem.

HTH,
C

#3 lore raw
Quoted 10 lines · Chris Brenton
Quoted 8 lines · Michael Gale

Inserting the following to the bottom of my firewall script:

### Causes all traffic to or from the box on either interface to be dropped regardless of all other rules.

iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables --policy FORWARD DROP

Quoted 7 lines

Try:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Works for me on multiple firewalls using multiple interfaces.

OK, now *I'm* confused. Aren't they the same command?

Jeff

#4 lore raw

On Tue, 2 Dec 2003 11:07:39 -0500,
Jeffrey Laramie <[email protected]> wrote in message <[email protected]>:

Quoted 17 lines · Chris Brenton
Quoted 16 lines · Michael Gale
Quoted 9 lines

Inserting the following to the bottom of my firewall script:

### Causes all traffic to or from the box on either interface to #be
dropped regardless of all other rules.

iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables --policy FORWARD DROP

Try:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Quoted 4 lines
Quoted 2 lines

Works for me on multiple firewalls using multiple interfaces.

OK, now *I'm* confused. Aren't they the same command?

..supposely, according to the man page, but if OP is using a development version off his own cvs tree or somesuch, all bets are off. ;-)

Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-)
...with a number of polar bear hunters in his ancestry...
  Scenarios always come in sets of three: 
  best case, worst case, and just in case.
#5 lore raw

Hello,

Thanks for the help so far -- it must of been the location I had placed the default policy in the file or maybe some other rule. But everything is working fine now.

Michael

Quoted 38 lines · On Tue, 2 Dec 2003 21:03:47 +0100 Arnt Karlsen <[email protected]> wrote:

On Tue, 2 Dec 2003 11:07:39 -0500,
Jeffrey Laramie <[email protected]> wrote in message <[email protected]>:

Quoted 17 lines · Chris Brenton
Quoted 16 lines · Michael Gale
Quoted 9 lines

Inserting the following to the bottom of my firewall script:

### Causes all traffic to or from the box on either interface to #be
dropped regardless of all other rules.

iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables --policy FORWARD DROP

Try:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Quoted 4 lines
Quoted 2 lines

Works for me on multiple firewalls using multiple interfaces.

OK, now *I'm* confused. Aren't they the same command?

..supposely, according to the man page, but if OP is using a development version off his own cvs tree or somesuch, all bets are off. ;-)

Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-)
...with a number of polar bear hunters in his ancestry...
  Scenarios always come in sets of three: 
  best case, worst case, and just in case.
Signature · 3 lines
Michael Gale
Network Administrator
Utilitran Corporation