Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将端口作为变量获取,我需要删除 nftables 中的规则。如果端口存在于规则中,那么我将 grep 句柄号并删除规则。但是在 nftables 中,服务名称会出现在规则中,所以我该如何删除规则。除了句柄或任何其他建议之外,有什么方法可以找到属于服务的端口或任何其他方法来删除 nftable 规则?
端口和服务名称列在 /etc/services 中。
您可以通过以下方式强制列表使用数字端口
nft -nna list ruleset/chain/set/table
我不知道用例,但可以通过使用命名集来实现更好的解决方案,从中可以轻松删除元素。