Monday, April 23, 2012

HowTo: Flush Iptables Under Ubuntu Linux

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

No comments:

Post a Comment