Skip to contentSkip to conversation

top level rules

DISCUSSION Patrick Ahler 6 participants 6 messages May 12, 2003

lore
Share & tools
lore
#0 lore raw

Is there any way to insert a new rule at the top of a table...

For instance, I have rules...

RULE 1
RULE 2
RULE 3
RULE 4

in order... but what if I want to place a rule before rule 1? Is that possible?
Thanks,
-Patrick

#1 lore raw
Quoted 11 lines · Patrick Ahler

Is there any way to insert a new rule at the top of a table...

For instance, I have rules...

RULE 1
RULE 2
RULE 3
RULE 4

in order... but what if I want to place a rule before rule 1? Is that possible?

Yes, just use the -I (insert) option of iptablesinstead of -A (append).

Regards,
Filip

#3 lore raw
In reply to Patrick Ahler

From the netfilter help (iptables --help)

"
--insert -I chain [rulenum]
Insert in chain as rulenum (default
1=first)
"

So ... iptable -I instead of iptables -A ....

Quoted 16 lines · Patrick Ahler

Is there any way to insert a new rule at the top of a table...

For instance, I have rules...

RULE 1
RULE 2
RULE 3
RULE 4

in order... but what if I want to place a rule before rule 1? Is that possible?
Thanks,
-Patrick

#5 lore raw
In reply to Patrick Ahler
Quoted 9 lines · Patrick Ahler

Is there any way to insert a new rule at the top of a table...

For instance, I have rules...

RULE 1
RULE 2
RULE 3
RULE 4

Quoted 4 lines

in order... but what if I want to place a rule before rule 1? Is that possible?
Thanks,
-Patrick

/sbin/iptables -I <table> 1........

you can substitute the number for any position in the table: 2, 3 4 etc etc.

cheers

Zander

#2 lore raw
In reply to Filip Sneppe

iptables -L -n --line0numbers will list the rule numbers iptables -I CHAINNAME rulenumber_to_insert REST OF RULE

----- Original Message -----
From: "Filip Sneppe" <[email protected]>
To: "Patrick Ahler" <[email protected]>
Cc: "netfilter EMAIL" <[email protected]>
Sent: Monday, May 12, 2003 8:49 AM
Subject: Re: top level rules

Quoted 21 lines · Patrick Ahler
Quoted 11 lines

Is there any way to insert a new rule at the top of a table...

For instance, I have rules...

RULE 1
RULE 2
RULE 3
RULE 4

in order... but what if I want to place a rule before rule 1? Is that possible?

Yes, just use the -I (insert) option of iptablesinstead of -A (append).

Regards,
Filip