美文网首页
批量添加iptables规则

批量添加iptables规则

作者: 六弦极品 | 来源:发表于2024-03-11 10:44 被阅读0次
#!/bin/bash
subnets=(10.110.12.10 10.110.12.11 10.110.12.12 10.110.12.13 10.110.12.14)

#多个端口使用空格隔开,连续的使用冒号,比如443:448,ports=(443:448 6443)
ports=(6443)
for port in ${ports[*]} ; do
    for subnet in ${subnets[*]} ; do
        echo iptables -A INPUT -p tcp -s $subnet --dport $port -j ACCEPT
    done
    echo iptables -A INPUT -p tcp --dport $port -j REJECT
done

相关文章

网友评论

      本文标题:批量添加iptables规则

      本文链接:https://www.haomeiwen.com/subject/bgjmzdtx.html