Routing Iptables:如何在链中轻松地对规则进行分组?
我有如下一些netfilter规则:Routing Iptables:如何在链中轻松地对规则进行分组?,routing,iptables,netfilter,chain,Routing,Iptables,Netfilter,Chain,我有如下一些netfilter规则: iptables -I INPUT -j NFQUEUE -p udp --dport 4444 iptables -t mangle -I INPUT -j MARK --set-mark 100 -p udp --dport 4444 iptables -I OUTPUT -j NFQUEUE -p udp --sport 4444 iptables -t mangle -I OUTPUT -j MARK --set-mark 200 -p udp --
iptables -I INPUT -j NFQUEUE -p udp --dport 4444
iptables -t mangle -I INPUT -j MARK --set-mark 100 -p udp --dport 4444
iptables -I OUTPUT -j NFQUEUE -p udp --sport 4444
iptables -t mangle -I OUTPUT -j MARK --set-mark 200 -p udp --sport 4444
我需要一个简单的方法来分组这些规则,目的是将它们全部删除,就像这样
iptables -N MYCHAIN
iptables -I MYCHAIN -j NFQUEUE -p udp --dport 4444
iptables -t mangle -I MYCHAIN -j MARK --set-mark 100 -p udp --dport 4444
iptables -I MYCHAIN -j NFQUEUE -p udp --sport 4444
iptables -t mangle -I MYCHAIN -j MARK --set-mark 200 -p udp --sport 4444
# Fast deleting
iptables -F MYCHAIN
iptables -X MYCHAIN
但它不起作用,当然我必须连接默认链和MYCHAIN,但我不知道如何连接。有更好或更简单的解决方案吗?链只存在于一个表中。如果运行
iptables-N MYCHAIN
,则在筛选器表中创建MYCHAIN
。如果要在mangle表中使用MYCHAIN
,也必须在其中创建
创建链后,可以使用以下链接将其链接到默认链:
iptables -A INPUT -j MYCHAIN