Skip to contentSkip to conversation

not sure if 'iptables -Z' needed/useful/superfluous here..

DISCUSSION [email protected] 3 participants 7 messages Jan 14, 2005 – Jan 17, 2005

lore
Share & tools
lore
#0 lore raw

When I want to start from scratch in my firewall
script I usually do this:

$IPTABLES -t filter -F
$IPTABLES -t mangle -F
$IPTABLES -t nat -F

$IPTABLES -t filter -X
$IPTABLES -t mangle -X
$IPTABLES -t nat -X

I'm not sure if -Z switch does anything useful after this violent scrubbing of my iptables...

$IPTABLES -Z

By the way... is this correct/better/wrong??

$IPTABLES -t filter -Z
$IPTABLES -t mangle -Z
$IPTABLES -t nat -Z

I read man page on iptables but it still was not clear if I need -Z to 'reset the byte count' and other stuff like it says it will do.

Thanks!

Chris

#1 lore raw
Quoted 6 lines · On Fri, 2005-01-14 at 01:03, [email protected] wrote:

When I want to start from scratch in my firewall
script I usually do this:

$IPTABLES -t filter -F
$IPTABLES -t mangle -F
$IPTABLES -t nat -F

which flushes all the rules out of those tables

Quoted 3 lines

$IPTABLES -t filter -X
$IPTABLES -t mangle -X
$IPTABLES -t nat -X

which deletes all chains in those tables.

Quoted 2 lines

I'm not sure if -Z switch does anything useful after this violent scrubbing of my iptables...

it still does what it would do any other time.

Quoted 3 lines

$IPTABLES -Z

By the way... is this correct/better/wrong??

if your intention is to zero your byte counters--then it's correct. if your intention is to retain your byte counters across reloads--then it's wrong.

Quoted 6 lines

$IPTABLES -t filter -Z
$IPTABLES -t mangle -Z
$IPTABLES -t nat -Z

I read man page on iptables but it still was not clear if I need -Z to 'reset the byte count' and other stuff like it says it will do.

people that rely on byte counters for accounting type uses probably don't use -Z when they reload their rules. i only use the counters as an indication of rule hits--so i do reset the counters every time i reload my rules. but it's not a question of right or wrong.

-j

--
"The only monster here is the gambling monster that has enslaved your
mother! I call him Gamblor, and it's time to snatch your mother from his neon claws!"
--The Simpsons

#2 lore raw

Jason

Thanks for your help. If I understood you correctly I can do 'iptables -Z' to zero out all tables at the same time or I can do

iptables -t filter -Z
iptables -t mangle -Z
iptables -t nat -Z

to do tables one at a time right?

Chris

Quoted 41 lines · Jason Opperisano
Quoted 6 lines · On Fri, 2005-01-14 at 01:03, [email protected] wrote:

When I want to start from scratch in my firewall
script I usually do this:

$IPTABLES -t filter -F
$IPTABLES -t mangle -F
$IPTABLES -t nat -F

which flushes all the rules out of those tables

Quoted 3 lines

$IPTABLES -t filter -X
$IPTABLES -t mangle -X
$IPTABLES -t nat -X

which deletes all chains in those tables.

Quoted 2 lines

I'm not sure if -Z switch does anything useful after this violent scrubbing of my iptables...

it still does what it would do any other time.

Quoted 3 lines

$IPTABLES -Z

By the way... is this correct/better/wrong??

if your intention is to zero your byte counters--then it's correct. if your intention is to retain your byte counters across reloads--then it's wrong.

Quoted 6 lines

$IPTABLES -t filter -Z
$IPTABLES -t mangle -Z
$IPTABLES -t nat -Z

I read man page on iptables but it still was not clear if I need -Z to 'reset the byte count' and other stuff like it says it will do.

people that rely on byte counters for accounting type uses probably don't use -Z when they reload their rules. i only use the counters as an indication of rule hits--so i do reset the counters every time i reload my rules. but it's not a question of right or wrong.

Quoted 9 lines

-j

--
"The only monster here is the gambling monster that has enslaved your
mother! I call him Gamblor, and it's time to snatch your mother from his neon claws!"
--The Simpsons

--
_______________________________________

Christian Seberino, Ph.D.
SPAWAR Systems Center San Diego
Code 2872
49258 Mills Street, Room 158
San Diego, CA 92152-5385
U.S.A.

Phone: (619) 553-9973
Fax : (619) 553-6521
Email: [email protected]
_______________________________________

#3 lore raw
Quoted 10 lines · On Fri, Jan 14, 2005 at 08:44:02AM -0800, [email protected] wrote:

Jason

Thanks for your help. If I understood you correctly I can do 'iptables -Z' to zero out all tables at the same time or I can do

iptables -t filter -Z
iptables -t mangle -Z
iptables -t nat -Z

to do tables one at a time right?

iptables -Z

will only zero out the filter table. you need to specify "-t nat" and "-t mangle" if you want to zero those as well. since this is all usually done in a script--i use:

for t in mangle nat filter; do
iptables -t $t -F
iptables -t $t -X
iptables -t $t -Z
done

but that's just me...i have much love for the loops.

-j

--
"I hope I didn't brain my damage."
--The Simpsons

#4 lore raw
In reply to [email protected]

i El vie, 14 de 01 de 2005 a las 07:03, [email protected]

Quoted 2 lines · escribió:

I read man page on iptables but it still was not clear if I need -Z to 'reset the byte count' and other stuff like it says it will do.

If you delete your rules there are no counters, so you don't need to reset them.

Signature · 12 lines
Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
[email protected]
bgSEC Seguridad y Consultoria de Sistemas Informaticos
http://www.bgsec.com
ESPAÑA

The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
                -- Jack Kerouac, "On the Road"
#5 lore raw
Quoted 8 lines · Jose Maria Lopez

i El vie, 14 de 01 de 2005 a las 07:03, [email protected]
escribió:

Quoted 2 lines

I read man page on iptables but it still was not clear if I need -Z to 'reset the byte count' and other stuff like it says it will do.

If you delete your rules there are no counters, so you don't need to reset them.

it will still reset the built-in chain counters.

-j

--
"I have been shot eight times this year, and as a result, I almost
missed work."
--The Simpsons

#6 lore raw
Quoted 7 lines · Jason Opperisano
Quoted 6 lines · Jose Maria Lopez

i El vie, 14 de 01 de 2005 a las 07:03, [email protected]

Quoted 2 lines · escribió:

I read man page on iptables but it still was not clear if I need -Z to 'reset the byte count' and other stuff like it says it will do.

Quoted 6 lines
Quoted 2 lines

If you delete your rules there are no counters, so you don't need to reset them.

it will still reset the built-in chain counters.

-j

You are right. I didn't have in mind that. I will change it in our bastion-firewall GPL software, because it uses the counters to get statisticals.

Thanks for the information and regards.

Signature · 12 lines
Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
[email protected]
bgSEC Seguridad y Consultoria de Sistemas Informaticos
http://www.bgsec.com
ESPAÑA

The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
                -- Jack Kerouac, "On the Road"