Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Are there any simpler commands to these? (e.g.: a oneliner? can one command reset iptables/netfilter settings to this?)

IPTABLES="$(which iptables)"

# RESET DEFAULT POLICIES
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT

# FLUSH ALL RULES, ERASE NON-DEFAULT CHAINS
$IPTABLES -F
$IPTABLES -X
$IPTABLES -t nat -F
$IPTABLES -t nat -X
$IPTABLES -t mangle -F
$IPTABLES -t mangle -X
share|improve this question
    
Did you write this script or if not, would you have the source? –  Dereckson Jul 14 at 11:01

1 Answer 1

up vote 4 down vote accepted

It only gets simpler if you know that you haven't changed some of these default chains. Other than that, no, this is as simple as it gets. except for the fact that you can put #!/bin/sh at the top and put it in a file and wham, one liner

share|improve this answer
    
Maybe if you have iptables as a module, you can unload it (and its cousins) and load it again? –  Gilles May 25 '11 at 22:54

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.