Flushing all iptables chain rules shell script
#!/bin/sh echo "Stopping IPv4 firewall and allowing everyone..." ipt="/sbin/iptables" ## Failsafe - die if /sbin/iptables not found [ ! -x "$ipt" ] && { echo "$0: \"${ipt}\" command not found."; exit 1; } $ipt -P INPUT ACCEPT $ipt -P FORWARD ACCEPT $ipt -P OUTPUT ACCEPT $ipt -F $ipt -X $ipt -t nat -F $ipt -t nat -X $ipt -t mangle -F $ipt -t mangle -X $ipt -t raw -F $ipt -t raw -X
Make sure you can execute the script using the chmod command:
# chmod +x /root/fw.stop
Run the script as root user:
# /root/fw.stop
Verify that my firewall rules are flushed out?
Type the following iptables command:
# iptables -L -n -v
Sample outputs:
Chain INPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination