有没有办法删除所有与给定接口有关的iptables规则? 我没有看到任何命令行选项,可能是这里有一个shorcut bash脚本?
一些可能性,取决于你的设置。
如果你正在运行一个相当简单的链结构,而不是嵌套和暗示,可以使用iptables-save来保存你的防火墙。 使用-i $ if或-o $删除所有行,具体取决于您的需要。 使用grep什么的。 保存该规则集,将其分配到您的第一个保存的规则集,如果没关系,则使用iptables-restore加载它。
另外 – 收集你的规则在特定于接口的链中。 这样,您可以轻松地迁移或删除接口。 而且你正在加快你的防火墙处理!
iptables -N fw-eth1 iptables -A FORWARD -o eth1 -j fw-eth1 iptables -A fw-eth1 --your-rules-here
添加一个规则来接受一个接口上的所有stream量: iptables -A INPUT -i eth0 -j ACCEPT ; iptables -A OUTPUT -o eth0 -j ACCEPT
iptables -A INPUT -i eth0 -j ACCEPT ; iptables -A OUTPUT -o eth0 -j ACCEPT
允许来自或去往该接口的所有stream量。
要删除所有的防火墙规则(我在读你的文字有疑问), iptables -P INPUT ACCEPT ; iptables -P OUTPUT ACCEPT ; iptables -P FORWARD ACCEPT ; iptables -X
iptables -P INPUT ACCEPT ; iptables -P OUTPUT ACCEPT ; iptables -P FORWARD ACCEPT ; iptables -X
iptables -P INPUT ACCEPT ; iptables -P OUTPUT ACCEPT ; iptables -P FORWARD ACCEPT ; iptables -X
:所有的交通是允许的。