是否有一种方法可以删除{
"reportRequests": [
{
object(ReportRequest)
}
],
}
中的多行而不知道自己的iptables
中的内容?
例如,我要删除端口80上的每个端口转发,这是iptables
:
iptables
是否可以在一个命令中删除这两行?
答案 0 :(得分:0)
这是一个有效的脚本:
iptables -t nat --list-rules PREROUTING | while IFS='' read -r line || [[ -n "$line" ]]; do
RULE443=$(echo $line | grep "REDIRECT --to-ports 8443")
RULE80=$(echo $line | grep "REDIRECT --to-ports 8080")
if [ "$RULE80" != '' ]
then
PORT80=$(echo $RULE80 | grep -o '\-\-dport.*' | cut -d' ' -f2)
iptables -t nat -D PREROUTING -p tcp --dport $PORT80 -j REDIRECT --to-port 8080
elif [ "$RULE443" != '' ]
then
PORT443=$(echo $RULE443 | grep -o '\-\-dport.*' | cut -d' ' -f2)
iptables -t nat -D PREROUTING -p tcp --dport $PORT443 -j REDIRECT --to-port 8443
fi
done