如何在Ubuntu Linux下清空所有IPv4和IPv6 iptables规则?
在iptables(IPv4)中查看当前规则:
1 2
| # -t如果不屑,默认为filter $ sudo iptables -L -t nat|mangle|filter
|
在ip6tables(IPv6)中查看当前规则:
1 2
| # -t如果不屑,默认为filter $ sudo ip6tables -L -t nat|mangle|filter
|
如何禁用(清空)IPv4防火墙?
如果需要禁用防火墙,则可以使用以下命令清除所有规则:
创建如下的shell脚本(例如/root/stop.fw):
1 2 3 4 5 6 7 8 9 10 11
| #!/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
|
安装下面方法运行:
1 2 3
| $ sudo chmod +x /root/stop.fw $ sudo /root/stop.fw $ sudo iptables -L
|
如何禁用(清空)IPv6防火墙?
如果需要禁用防火墙,则可以使用以下命令清除所有规则:
创建如下的shell脚本(例如/root/stop6.fw):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #!/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
|
按照下面方法运行:
1 2 3
| $ sudo chmod +x /root/stop6.fw $ sudo /root/stop6.fw $ sudo ip6tables -L
|