A PHP Library for IPTables
Dear users
I would like you to just know that I've written a lightweight library in PHP that enables you manipulate iptables chains and rules. You can download it at: https://sourceforge.net/projects/libiptphp/ Feel free to contact me in case of any comment. |
Looks interesting.
Still, would be good to have some example of using this library ? Would be easier to understand the exact way to use the class. Best regards, |
Of course an example will help you understand it. An article is going to be published in Linux Journal. But, I'm thinking of including a sample rule file and an example PHP script that uses it.
|
Quote:
Thank you. |
Could you post a small example here so we could get a quick glimpse? I'm pretty sure that if one was within the forums, you would get more people to try your library out.
|
OK. The following simple code lists tables, chains, and rules defined in iptables rules file.
Code:
<?php |
hai koosha. thank you for your code.
i try to get byte couter using getRuleByteCounter function, but it shows nothing. here is my code, correct me please. Code:
<?php thank you very much for help :) |
Quote:
Two points: 1. Your rule MUST begin with counters; that is, it must have counters; otherwise it is reasonable that nothing is returned if your rule does not have counters. Rules which begin with [1234:5678] (ignore the numbers, consider the form [\d+:\d+]) have byte and packet counters set. 2. getRuleByteCounter() does not return an array; it returns an integer. So it should be used as a stand-alone statement not in a foreach loop. |
All times are GMT -5. The time now is 11:52 PM. |