Manage IP tables with the pref API. Php

Hi guys, there is an API, so I can manage IPTables with PHP, it is for the project to build a router with a browser login similar to Fonera. Any thoughts are welcome.

+4
source share
3 answers

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

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

+1
source

I think the easiest way is to use exec () to run IPtables commands. Perhaps use your PHP to create a script, and then run this at the end. I don’t think there is an β€œAPI” to manage IPtables with only the executable in many Linux distributions.

+1
source

You can install rfw , which is the REST API for iptables and works 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.

Command example:

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 this project.

+1
source

All Articles