好的,这是全新安装的CentOs 7(最小)。
这是iptables -L
Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain FORWARD_IN_ZONES (0 references) target prot opt source destination Chain FORWARD_IN_ZONES_SOURCE (0 references) target prot opt source destination Chain FORWARD_OUT_ZONES (0 references) target prot opt source destination Chain FORWARD_OUT_ZONES_SOURCE (0 references) target prot opt source destination Chain FORWARD_direct (0 references) target prot opt source destination Chain FWDI_public (0 references) target prot opt source destination Chain FWDI_public_allow (0 references) target prot opt source destination Chain FWDI_public_deny (0 references) target prot opt source destination Chain FWDI_public_log (0 references) target prot opt source destination Chain FWDO_public (0 references) target prot opt source destination Chain FWDO_public_allow (0 references) target prot opt source destination Chain FWDO_public_deny (0 references) target prot opt source destination Chain FWDO_public_log (0 references) target prot opt source destination Chain INPUT_ZONES (0 references) target prot opt source destination Chain INPUT_ZONES_SOURCE (0 references) target prot opt source destination Chain INPUT_direct (0 references) target prot opt source destination Chain IN_public (0 references) target prot opt source destination Chain IN_public_allow (0 references) target prot opt source destination Chain IN_public_deny (0 references) target prot opt source destination Chain IN_public_log (0 references) target prot opt source destination Chain OUTPUT_direct (0 references) target prot opt source destination
我的印象是应该只有一个INPUT,FORWARD和OUTPUT链(至less在我的CentOs 6盒子上是这样的)。
我怎样才能删除一切?
作为netfilter内核的一部分,有less量的默认链:INPUT,FORWARD和OUTPUT,但是你或者通常你的工具可以自由地创build额外的链来为你的防火墙configuration带来结构。
你所看到的是新的,没有错的,防火墙configuration工具firewalld的结果( Shorewall等其他工具也可能会创build任意数量的附加链)。
去掉这些额外的链条,但不明白是什么创造了它们,可能是徒劳的,或者现在或将来都可能破坏事物。 使用RHEL / CentOS 7,你应该使用firewall-cmd来pipe理你的防火墙,不再需要手动编辑/etc/sysconfig/iptables 。
你很沮丧,但仍然可以恢复到Enterprise Linux 6和更老的pipe理你的防火墙configuration的风格,并使用iptables和ip6tables服务而不是firewalld。
首先以根用户身份运行以下命令来禁用firewalld:
systemctl disable firewalld systemctl stop firewalld
然后通过以root身份input以下命令来安装iptables-services软件包:
yum install iptables-services
但要回答你的直接问题:pipe理链条是有据可查的 :
创build一个新链:使用-N或--new-chain选项:
iptables -N test
删除链:删除链也很简单,使用-X或--delete-chain选项。 为什么-X ? 那么,所有的好信都被拿走了。
iptables -X test
删除链有两个限制:它们必须是空的(请参阅下面的“刷新链”),它们不能成为任何规则的目标。 您不能删除三个内置链中的任何一个。
刷新链:使用-F (或--flush )命令可以简单地从链中清空所有规则。
iptables -F test
你在这里已经连锁input/输出/前锋:-)
Rest – 在RHEL7 / CentOS7 firewalld中默认使用。
你通常有两种可能性:
你可以和firewalld交朋友,而不是使用iptables规则 – 使用firewalld。 对于控制防火墙 – 您有防火墙cmd命令。 您调用时的当前规则列表
firewall-cmd –list-all-zones
更多信息 – 你在网页http://fedoraproject.org/wiki/FirewallD