Press "Enter" to skip to content

iptables delete some rules form a chain

以下两条命令均可用

iptables -t nat -L PREROUTING --line-numbers | grep RULE_NAME | cut -d" " -f 1 | xargs iptables -t nat -D PREROUTING

for i in $(iptables -t nat -nvL PREROUTING --line-numbers | grep RULE_NAME | grep ^[0-9] | awk '{ print $1 }' | tac); do iptables -t nat -D PREROUTING $i; done
Leave a Reply

Your email address will not be published. Required fields are marked *