HowTo: Flush Iptables Under Ubuntu Linux

by on November 18, 2010 · 1 comment· LAST UPDATED November 18, 2010

in

How do I flush all IPv4 and IPv6 iptables rules under Ubuntu Linux?

To see your current rules in iptables (IPv4), enter:
$ sudo iptables -L
To see your current rules in ip6tables (IPv6), enter:
$ sudo ip6tables -L

How Do I Disable (flush) IPv4 Firewall?

If you need to disable the firewall, you can flush all the rules using the following command:
$ sudo iptables -F
Create a shell script as follows (say /root/stop.fw) :

#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

Run it as follows:
$ sudo chmod +x /root/stop.fw
$ sudo /root/stop.fw
$ sudo iptables -L

How Do I Disable (flush) IPv6 Firewall?

If you need to disable the firewall, you can flush all the rules using the following command:
$ sudo ip6tables -F
Create a shell script as follows (say /root/stop6.fw) :

#!/bin/sh
IPT6="/sbin/ip6tables"
echo "Stopping IPv6 firewall..."
$IPT6 -F
$IPT6 -X
$IPT6 -Z
for table in $(</proc/net/ip6_tables_names)
do
        $IPT6 -t $table -F
        $IPT6 -t $table -X
        $IPT6 -t $table -Z
done
$IPT6 -P INPUT ACCEPT
$IPT6 -P OUTPUT ACCEPT
$IPT6 -P FORWARD ACCEPT
 

Run it as follows:
$ sudo chmod +x /root/stop6.fw
$ sudo /root/stop6.fw
$ sudo ip6tables -L

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 vicank July 3, 2014 at 2:02 pm

It worked like a charm..
Thanks a lot.. :)

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: