以编程方式修改Linux防火墙规则
我需要使用编程在防火墙中分配规则。我的意思是我想创建一个 Web 应用程序,用户可以在其中为其 IP 地址选择防火墙规则,并且这些规则将分配给该 IP。只会有一台防火墙机器。我认为具有良好 api 的防火墙可以做到这一点。有人知道有好的API的开源防火墙吗?
I need to assign rules in my firewall using programming.. I mean I want to create a web app in which user can select the firewall rules for their ip address and those rules will be assigned to that IP. There would be only one firewall machine. I think a firewall with nice api will do this. Anyone knows open source firewall with good api??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Linux 防火墙称为
netfilter
,是Linux 内核的一部分。有多种用户空间工具可以操作它,最引人注目的是事实上的标准实用程序 iptables。由于您需要成为 root 才能修改防火墙规则,并且 Web 服务器不应该以 root 身份运行,因此我建议采用两层方法来解决此问题:一个修改一组规则的 Web 应用程序规则(在 SQL 数据库或配置文件中),以及以 root 身份运行的守护程序,该守护程序监视规则更改并通过执行 iptables 来应用它们。The linux firewall is called
netfilter
and is a part of the linux kernel. There are various userland tools which manipulates it, most notably the de-facto standard utilityiptables
. As you need to be root in order to modify firewall rules, and web servers should not run as root, I'd recommend a two-tier approach to solving this: A web app which modifies a set of rules (in a SQL db, or a config file), and a daemon running as root which monitors for rule changes and applies them by executingiptables
.