Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to delete all iptables rules, that relate to a given interface? I don't see any command line option for this, may be there is a shorcut bash script for this?

share|improve this question
    
I could be wrong but I don't think iptables usually keeps a record of interfaces. If you're using debian/ubuntu, /etc/network/interfaces keeps a record of interfaces and IP addresses, so maybe you could whip up a script that cross-references that? –  smcg Aug 21 '12 at 15:55
    
@smcg it should keep it. Try iptables -L -v for detailed output. –  FractalizeR Aug 23 '12 at 17:59

2 Answers 2

Some possibilities, depending on your setup.

If you are running a quite simple structure of chains and dont to nesting and implications, use iptables-save to save your firewallset. Remove all lines with -i $if or -o $if, depending on your needs. Use grep or something. Save that ruleset, diff it to your first saved ruleset and if it's okay, load it with iptables-restore.

Alternatively - gather your rules in interface-specific chains. That way you can easily migrate or remove interfaces. And you are going speed up your firewall processing!

iptables -N fw-eth1
iptables -A FORWARD -o eth1 -j fw-eth1
iptables -A fw-eth1 --your-rules-here
share|improve this answer

Add a rule to accept all the trafic on one interface : iptables -A INPUT -i eth0 -j ACCEPT ; iptables -A OUTPUT -o eth0 -j ACCEPT All the trafic from or to this interface is allowed.

To delete all the firewall rules (I have a doubt in reading your text), iptables -P INPUT ACCEPT ; iptables -P OUTPUT ACCEPT ; iptables -P FORWARD ACCEPT ; iptables -X : all the trafic is allowed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.