开发者

Managing IPTables with API pref. php [closed]

Closed. This question is seeking recommendations for books, tools, softwa开发者_运维技巧re libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

Is there an API so I can manage IPTables with PHP, it's for a project to build a router with a browser login, kinda the same as a Fonera?


This may solve your problem. The tricky part is sudo for apache process and tracking, rest is standard php and iptables:

http://www.andybev.com/index.php/Using_iptables_and_PHP_to_create_a_captive_portal


I think easiest way would be to use exec() for firing IPtables commands. Maybe use your PHP to create a script and then execute that in the end. I don't think there is an "API" to control IPtables only the executable in a lot Linux Distributions.


You can install rfw which is the REST API for iptables and runs as a server with root privileges. Clients can use any HTTP API without special rights, so you can use curl from PHP to send commands to rfw.

Sample command:

PUT /drop/input/eth0/11.22.33.44

which corresponds to:

iptables -I INPUT -i eth0 -s 11.22.33.44 -j DROP

Disclaimer: I started that project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜