Download the PHP package azurre/iptables without Composer
On this page you can find all versions of the php package azurre/iptables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download azurre/iptables
More information about azurre/iptables
Files in azurre/iptables
Package iptables
Short Description Class to manage entries in iptables.
License GPL-3.0
Informations about the package iptables
Parser for iptables
iptable library allows you to quick and easy parse and manipulate iptables records via PHP. As a main feature it parse raw iptable dump and build full objected tree with chains and rules. It moves almost all functionality which give you iptables.
Not all patches are implemented - for my purposes there was no need to do that - but it should be enough for most use cases.
Installation
The simpliest way to install iptables is by the composer.
Of course you can also download that repository and load all classes from src into your project (don't forget to load all required files).
Usage
Parsing raw iptables dump build chains tree connected to one of five default tables in iptables
.
As result of above code you should get Table
object with Chain
collection:
Connections
Each Table
got Chains
and each Chain
got Rules
with properties which describes all selected options.
Using iptables class you can simply find specified chain and get list of all rules in it.
Example
Some examples you can check directly in tests. But for quick review I also put it here.
Let's get that iptables settings and we want edit first record - set source to 127.0.0.1
:
I assume that we already have parsed table under $result
var, so the easiest way to do that is:
First rule in object has been changed and in result we got command in $cmd
:
Command
Command class allows you to generate plain shell commands to manage iptables (only return as strings without execute!).
Please make sure that you first set all options (setters like setMatch()
, setProtocol()
etc.), and after that call action method, because that methods return
strings so it is imposibble to chaining.