简体   繁体   English

iptables的替代品?

[英]Alternatives for iptables?

I'm developing an application in which i rely heavily on iptables for routing traffic. 我正在开发一个应用程序,其中我非常依赖iptables路由流量。 I'm setting the tables just by calling iptables as an external process from my application. 我只是通过从应用程序中调用iptables作为外部进程来设置表。

I would like to know if there is a way to directly talk to the kernel modules (Netfilter) on which iptables relies and avoid the overhead of running a new process just for that? 我想知道是否有一种方法可以直接与iptables依赖的内核模块(Netfilter)进行通信,并避免为此目的运行新进程的开销?

Recommendations for other routing solutions are welcome. 欢迎提供其他路由解决方案的建议。

I don't see any problem with netfilter. 我看不到netfilter有任何问题。 You are able to bind your callback on any netfilter hooks and kernel will invoke your callback on hook event. 您可以在任何netfilter钩子上绑定回调,内核将在钩子事件上调用您的回调。 You are doing this via nf_register_hook . 您正在通过nf_register_hook进行此操作。 You can even track connections with conntrack 您甚至可以使用conntrack跟踪连接

Example for this is here . 例子在这里

More info about hacking netfilter on official documentation 有关在官方文档中入侵netfilter的更多信息

If my understanding is correct, you are asking for a programatic interface for the configuration of iptables. 如果我的理解是正确的,那么您正在要求一个用于iptables配置的程序接口。 Unfortunately iptables (libiptc) doesn't give an API interface for configuring or querying them, its way too low in the stack. 不幸的是,iptables(libiptc)没有提供用于配置或查询它们的API接口,它在堆栈中的位置太低了。

One alternative I can suggest is kernel IP sets. 我可以建议的另一种选择是内核IP集。 ipset is actually an extension to iptables that allows to create rules that match entire set of addresses at once. ipset实际上是iptables的扩展,它允许一次创建与整个地址集匹配的规则。 IPtables are traversed linearly where as ip set are stored in indexed data structures. IPtables线性遍历,其中ip set存储在索引数据结构中。 This makes it very efficient. 这使其非常有效。

https://packages.debian.org/sid/net/ipset

This may not be a direct answer to your question but hope it helps. 这可能不是您问题的直接答案,但希望能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM