How can I programmatically manage iptables rules on the fly?

后端 未结 9 1262
盖世英雄少女心
盖世英雄少女心 2020-11-29 00:20

I need to query existing rules, as well as being able to easily add and delete rules. I haven\'t found any API\'s for doing this. Is there something that I\'m missing?

9条回答
  •  感情败类
    2020-11-29 01:11

    There is deliberately no API to manage these rules. You're not supposed to want to do so. Or something.

    If you need rules which are sufficiently dynamic you care about the performance of executing /sbin/iptables, there are other ways to do it:

    • Using something like the "recent" match or ip set matching, you can add/remove IP addresses from black/white lists without changing the rule set.
    • You can pass packets into userspace for filtering using NFQUEUE

提交回复
热议问题