jinliming2
2022-08-06 09:34:06 +08:00
nftables ?复制一个模板文件,然后自己改就行,如果仅仅是实现安全组的功能,完全都不用查文档?改完用 nft 执行一下这个文件就更新了?
比如我的模板:
> #!/sbin/nft -f
> flush ruleset
> table inet firewall {
>   chain input {
>     type filter hook input priority 0; policy drop; # 默认全部丢弃
>     ct state established, related accept # 不干扰已建立的连接
>     iifname { lo } accept # 接受本地回环
>     ip saddr { 192.168.0.0/23 } tcp dport { 22, 44380, 44388 } accept # 接受指定 ip 范围对指定目标端口的 TCP 访问
>     icmp type echo-request accept # 允许 IPv4 Ping
>     icmpv6 type { echo-request, nd-router-solicit, nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } accept # 允许 IPv6 Ping
>   }
> }