Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clear iptables rules 1

Status
Not open for further replies.

nix45

MIS
Nov 21, 2002
478
US
How do you clear all of your iptables rules, without booting anybody from the server? If you run "iptables -F", it will clear the rules, but no one will be able to connect to the server afterwards. You can't even ftp to localhost, for example. I basically just want to know the command to turn iptables off.

Thanks,
Chris
 
You also need to change default policies.

#!/bin/sh
echo "Flushing all current rules and user defined chains:"
iptables -F
echo "Clearing all current rules and user defined chains:"
iptables -X
chains=`cat /proc/net/ip_tables_names 2>/dev/null`
for i in $chains; do iptables -t $i -F; done && echo "Flushing all current rules and user defined chains OK" || echo "Flushing all current rules and user defined chains FAILED"
for i in $chains; do iptables -t $i -X; done && echo "Clearing all current rules and user defined chains OK" || echo "Clearing all current rules and user defined chains FAILED"
for i in $chains; do iptables -t $i -Z; done

iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top