Skip to contentSkip to conversation

Order in ruleset edition

DISCUSSION Alejandro Cabrera Obed 4 participants 5 messages Nov 26, 2003

lore
Share & tools
lore
#0 lore raw

Hi !!!
I'm trying to construct my own ruleset of iptables; I'm editing a file script.

My question is the following:

Is there any order about CHAINS and TABLES that I have to follow in order to construct my iptables ruleset ??? For example, is it the same if firstly I write in my script my the FORWARD rules and then the OUTPUT and INPUT rules or viceversa ???

Thanks a lot and regards !!!

Alejandro.

#1 lore raw

Good afternoon, Alejandro,

Quoted 9 lines · Alejandro Cabrera Obed

I'm trying to construct my own ruleset of iptables; I'm editing a file script.

My question is the following:

Is there any order about CHAINS and TABLES that I have to follow in order to construct my iptables ruleset ??? For example, is it the same if firstly I write in my script my the FORWARD rules and then the OUTPUT and INPUT rules or viceversa ???

There isn't a difference in the final outcome, no.

However, unless you're blocking all traffic until the firewall is
completely constructed, the second and third chains you construct will be left unprotected longer (on the order of 1-5 seconds or so). It's a minor consideration, but I've seen an attack that sneaked through a firewall as it was being reloaded.
Cheers,
- Bill

---------------------------------------------------------------------------
"Don't say you don't have enough time. You have exactly the
same number of hours per day that were given to Helen Keller, Pasteur, Michaelangelo, Mother Teresa, Leonardo da Vinci, Thomas Jefferson, and Albert Einstein."
-- H. Jackson Brown
(Courtesy of <[email protected]>)
--------------------------------------------------------------------------
William Stearns ([email protected]). Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at: http://www.stearns.org
Linux articles at: http://www.opensourcedigest.com
--------------------------------------------------------------------------

#2 lore raw
In reply to Alejandro Cabrera Obed
Quoted 4 lines · Alejandro Cabrera Obed

Is there any order about CHAINS and TABLES that I have to follow in order to construct my iptables ruleset ??? For example, is it the same if firstly I write in my script my the FORWARD rules and then the OUTPUT and INPUT rules or viceversa ???

I recommend:

1. Turn off kernel forwarding:
echo 0 >/proc/sys/net/ipv4/ip_forward

2. Apply default DROP policies to all chains:
iptables -P DROP INPUT
iptables -P DROP OUTPUT
iptables -P DROP FORWARD

3. Flush any old rules:
iptables -F
iptables -F -t nat
iptables -F -t mangle (well, you never know...)

4. Create the rules to allow the packets you want. The order in which you
create them is not important, so long as the order they end up in does the
job you want. Do not change the default DROP policies :)

5. Turn on kernel forwarding again:
echo 1 >/proc/sys/net/ipv4/ip_forward

I regard the above as a safe way to create rules without allowing thing to sneak in or through whilst you're doing it.

Antony.

Signature · 4 lines
Ramdisk is not an installation procedure.

                                                     Please reply to the list;
                                                           please don't CC me.
#3 lore raw
In reply to Alejandro Cabrera Obed
Quoted 6 lines · Alejandro Cabrera Obed

Hi !!!
I'm trying to construct my own ruleset of iptables; I'm editing a file script.

Alejandro,

The script you sent me was cut off before it got to the rules you added. Can you post your rules here on the list in text so everyone can see them. You've got lots of help today :-)

Aside: Where were all you guys earlier this week when Mark and I were trying to bunt fastballs?

Jeff

#4 lore raw
Quoted 2 lines · Jeffrey Laramie

Aside: Where were all you guys earlier this week when Mark and I were trying to bunt fastballs?

Trying to replace a 256kbps leased line (with 32 public IPs) with a 2Mbps satellite link (with 1 private IP), and a VPN to somewhere else which has 8 public IPs on an ADSL....

If it works, I'm gonna be amazed....

Antony

Signature · 6 lines
90% of networking problems are routing problems.
9 of the remaining 10% are routing problems in the other direction.
The remaining 1% might be something else, but check the routing anyway.

                                                     Please reply to the list;
                                                           please don't CC me.