Skip to content

Commit 5aec00e

Browse files
authored
Merge pull request #144 from polycube-network/pr/iptables_doc
pcn-iptables: update and unify documentation
2 parents 1cbb62c + 45e7f4f commit 5aec00e

2 files changed

Lines changed: 46 additions & 67 deletions

File tree

Documentation/components/iptables/pcn-iptables.rst

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
pcn-iptables: An iptables clone based on eBPF
22
=============================================
33

4-
**Disclaimer**: this guide is still a draft
5-
64
Polycube comes with ``iptables`` application (in brief ``pcn-iptables``) that provides an iptables clone, with compatible syntax and semantic.
75
The backend is based on `eBPF` programs, more efficient algorithms and runtime optimizations.
86
The frontend provides same iptables CLI, users can setup security policies using same syntax.
@@ -13,7 +11,7 @@ Supported features
1311
Currently supported features:
1412

1513
- Support for ``INPUT``, ``OUTPUT``, ``FORWARD`` chains
16-
- Support for ``ip``, ``protocol``, ``ports``, ``tcp flags``
14+
- Support for ``ip``, ``protocol``, ``ports``, ``tcp flags``, ``interfaces``
1715
- Support for ``connection tracking``
1816
- Support for bpf ``TC`` and ``XDP`` mode
1917

@@ -25,6 +23,8 @@ Detailed supported parameters
2523
- ``--sport`` source port
2624
- ``--dport`` destination port
2725
- ``--tcpflags`` tcp flags
26+
- ``-i`` input interface
27+
- ``-o`` output interface
2828
- ``-m conntrack --ctstate`` conntrack module
2929

3030
Detailed supported targets
@@ -46,20 +46,40 @@ Limitations
4646
^^^^^^^^^^^
4747

4848
- No support for multiple chains
49-
- No support for ``-i`` ``-o`` interfaces
5049
- No support for ``SNAT``, ``DNAT``, ``MASQUESRADE``
5150
- ``-S`` ``-L`` generate an output slightly different from iptables
5251

5352
Install
5453
-------
5554

56-
For ``pcn-iptables`` support you should enable ``ENABLE_PCN_IPTABLES`` flag in CMakeFile.
55+
Prerequisites
56+
^^^^^^^^^^^^^
57+
58+
pcn-iptables comes as a component of polycube framework.
59+
Refer to :doc:`polycube install guide<../../../installation>` for dependencies, kernel requirements and basic checkout and install guide.
60+
61+
Install Steps
62+
^^^^^^^^^^^^^
63+
64+
To compile and install ``pcn-iptables``, you should enable the ``ENABLE_PCN_IPTABLES`` flag in the polycube CMakeFile, which is set to ``OFF`` by default;
65+
this allows to compile the customized version of ``iptables`` used to translate commands, and install in the system pcn-iptables-init pcn-iptables and pcn-iptables-clean utils.
66+
67+
Note:
68+
The ``ENABLE_SERVICE_IPTABLES`` flag, which is set to ``ON`` by default, is used to compile and install the ``libpcn-iptables.so`` service (like other polycube services: bridge, router, ..).
69+
This flag is required to be enabled as well, but it comes by default.
70+
5771
::
5872

59-
cd polycube/build/
60-
cmake .. -DENABLE_PCN_IPTABLES=ON
61-
make && make install
6273

74+
cd polycube
75+
76+
# hint: ensure git submodules are updated
77+
# git submodule update --init --recursive
78+
79+
mkdir -p build
80+
cd build
81+
cmake .. -DENABLE_PCN_IPTABLES=ON
82+
make && sudo make install
6383

6484
Run
6585
---
@@ -128,5 +148,20 @@ XDP mode
128148
Limitations
129149
^^^^^^^^^^^
130150

131-
- It requires your network interfaces to support XDP Native mode
132-
- If any interface is not supporting XDP, on such interface traffic is not filtered
151+
- pcn-iptables operates only on interfaces that support XDP native mode
152+
- traffic is not filtered on interfaces that support only eBPF TC programs.
153+
154+
pcn-iptables components
155+
-----------------------
156+
157+
iptables submodule
158+
^^^^^^^^^^^^^^^^^^
159+
160+
A customized fork of iptables is included as submodule under :scm_web:`src/components/iptables/iptables <src/components/iptables>`.
161+
We customized this version of iptables in order not to inject iptables command into netfilter, but convert them, after a validation step, into polycube syntax.
162+
163+
scripts folder
164+
^^^^^^^^^^^^^^
165+
166+
Scripts are used as a glue logic to make pcn-iptables run. Main purpose is initialize, cleanup and run pcn-iptables, pass pcn-iptables parameters through iptables (in charge of converting them), then pass converted commands to pcn-iptables service.
167+
Scripts are installed under ``/usr/local/bin``.

src/components/iptables/README.md

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,3 @@
11
# Iptables Service
2-
`pcn-iptables` service is intended to emulate `iptables` using same semantic but different backend, based on `eBPF` programs and more efficients algorithms and runtime optimizations.
32

4-
## Steps to INSTALL pcn-iptables
5-
6-
For `pcn-iptables` support you should enable `ENABLE_PCN_IPTABLES` flag in CMakeFile.
7-
```
8-
cd polycube
9-
mkdir -p build
10-
cd build
11-
cmake .. -DENABLE_PCN_IPTABLES=ON
12-
make && sudo make install
13-
```
14-
15-
## Steps to RUN pcn-iptables
16-
17-
### 1. Initialization, start `pcn-iptables` service
18-
19-
```
20-
# Start polycubed, in other terminal (or background)
21-
sudo polycubed
22-
# run pcn-iptables-init.
23-
pcn-iptables-init
24-
```
25-
26-
### 2. Use pcn-iptables, with same syntax of iptables
27-
```
28-
# E.g.
29-
pcn-iptables -A INPUT -s 10.0.0.1 -j DROP # Append rule to INPUT chain
30-
pcn-iptables -D INPUT -s 10.0.0.1 -j DROP # Delete rule from INPUT chain
31-
pcn-iptables -I INPUT -s 10.0.0.2 -j DROP # Insert rule into INPUT chain
32-
33-
pcn-iptables -S # dump rules
34-
pcn-iptables -L INPUT # dump rules for INPUT chain
35-
36-
pcn-iptables -P FORWARD DROP # set default policy for FORWARD chain
37-
```
38-
39-
**NOTE**: do _not_ use use `sudo pcn-iptables ...`
40-
41-
### 3. Cleanup, stop `pcn-iptables` service
42-
43-
```
44-
# run pcn-iptables-clean
45-
pcn-iptables-clean
46-
```
47-
48-
49-
## pcn-iptables components
50-
51-
### iptables submodule
52-
53-
Under `src/components/iptables/iptables` a customized fork of iptables is included as submodule.
54-
We customized this version of iptables in order not to inject iptables command into netfilter, but convert them, after a validation, into polycube syntax.
55-
56-
### scripts folder
57-
58-
Scripts are used as a glue logic to make pcn-iptables run. Main purpose is initialize, cleanup and run pcn-iptables, pass pcn-iptables parameters through iptables (in charge of converting them), then pass converted commands to pcn-iptables service.
59-
Scripts are installed under `/usr/local/bin`.
3+
[Refer to pcn-iptables documentation](./../../../Documentation/components/iptables/pcn-iptables.rst)

0 commit comments

Comments
 (0)