LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   iptables (https://www.linuxquestions.org/questions/linux-security-4/iptables-215674/)

Obie 08-10-2004 03:41 AM

iptables
 
I wish to query if it would be advisable to flush my current iptables configuration which was configured automatically during the installation of Linux. The reason I wish to flush is

1) Start anew
2) Learn how to write iptables

I understand from the man pages I can save my current configuration by issuing the command iptables-save however am unsure how to use it should the need arise to restore it. I appreciate any advice.

ppuru 08-10-2004 04:03 AM

On RedHat/Fedora, iptables rules are saved in /etc/sysconfig/iptables. You can rename this to iptables.old.

After this you can restart your iptables. This will prevent the rules created by RedHat install from loading at boot.

If your system is connected to the internet, please disconnect before you turn iptables off.

barisdemiray 08-10-2004 04:03 AM

You can use it like these:

For backing up rules
#iptables-save > iptables.backup

and restoring them
#iptables-restore < iptables.backup

Hope these helps.

Obie 08-10-2004 04:07 AM

Thanks guys. ppuru, your advice was helpful unfortunately I have stopped using Red Hat 9 and opted a distribution with the latest kernel and stock security.

Obie 08-10-2004 04:22 AM

create iptables
 
I just flushed my iptables and am starting a new. Now if I wish to block all output my understanding of writing iptables is

iptables -A OUTPUT -p all -i eth0 -j DROP

Would this be correct?

ppuru 08-10-2004 04:30 AM

Obie

We could have continued this discussion on your earlier post at

http://www.linuxquestions.org/questi...hreadid=215674

Obie 08-10-2004 04:33 AM

sorry ppuru as I thought my question had been answered, I should start a new thread. I do apologise. If the moderators could somehow merge them I would be happy to continue from where I left off.

Meanwhile, I came across this script:
# Iptables firewall reset script
*filter
:INPUT ACCEPT [164:15203]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [147:63028]
COMMIT

*mangle
:PREROUTING ACCEPT [164:15203]
:INPUT ACCEPT [164:15203]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [147:63028]
:POSTROUTING ACCEPT [147:63028]
COMMIT

*nat
:PREROUTING ACCEPT [14:672]
:POSTROUTING ACCEPT [9:684]
:OUTPUT ACCEPT [9:684]
COMMIT

What does the numbers e.g. [164:15203] represent?

ppuru 08-10-2004 04:42 AM

the packets and bytes that these rules have handled...

Obie 08-10-2004 04:47 AM

ppuru,

sorry I don't follow. Would you mind giving an example and also what would happen if it was simply [0:0]

Obie 08-10-2004 04:56 AM

Also I noticed although I flushed my iptables i.e. iptables --flush it still has Chain INPUT (policy drop) rather than Chain INPUT (policy ACCEPT) Why is that?

ppuru 08-10-2004 05:12 AM

Quote:

sorry I don't follow. Would you mind giving an example and also what would happen if it was simply [0:0]
try iptables -Z. this will set the counters to [0:0].

barisdemiray 08-10-2004 05:14 AM

Quote:

Originally posted by Obie
Also I noticed although I flushed my iptables i.e. iptables --flush it still has Chain INPUT (policy drop) rather than Chain INPUT (policy ACCEPT) Why is that?
When you flush only the rules will be cleaned but global policy will remain same. To change them use the command

Code:

iptables -P INPUT ACCEPT
Also a descriptive part from the man page of iptables:

Quote:

Flush the selected chain (all the chains in the table if none is given). This is equivalent to deleting all the rules one by one.

Capt_Caveman 08-10-2004 06:57 AM

Quote:

Originally posted by Obie
If the moderators could somehow merge them I would be happy to continue from where I left off.
Done :)

Obie 08-10-2004 03:51 PM

Capt_Caveman,

Sweet. I didn't know merging them would be possible but thank you.

ppuru,

I still don't follow what the numbers represent and how they work

-----------------------------------------------------------------
ppuru's quote:
try iptables -Z. this will set the counters to [0:0]
-----------------------------------------------------------------

barisdemiray,

Thank you for providing an example however I wish to understand when does it change to drop from accept and vice versa

-----------------------------------------------------------------
barisdemiray's quote:
When you flush only the rules will be cleaned but global policy will remain same. To change them use the command
iptables -P INPUT ACCEPT
-----------------------------------------------------------------

Obie 08-10-2004 04:42 PM

Another query,

What does -I INPUT do exactly. I understand what -A(APPEND), -D(DELETE) and -R(REPLACE) do but still don't quite follow -I? Also whenever a guide for example refers to say "slot 3" does it mean the third line within say the INPUT chain?


All times are GMT -5. The time now is 12:55 PM.