You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/components/iptables/pcn-iptables.rst
+45-10Lines changed: 45 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,6 @@
1
1
pcn-iptables: An iptables clone based on eBPF
2
2
=============================================
3
3
4
-
**Disclaimer**: this guide is still a draft
5
-
6
4
Polycube comes with ``iptables`` application (in brief ``pcn-iptables``) that provides an iptables clone, with compatible syntax and semantic.
7
5
The backend is based on `eBPF` programs, more efficient algorithms and runtime optimizations.
8
6
The frontend provides same iptables CLI, users can setup security policies using same syntax.
@@ -13,7 +11,7 @@ Supported features
13
11
Currently supported features:
14
12
15
13
- Support for ``INPUT``, ``OUTPUT``, ``FORWARD`` chains
16
-
- Support for ``ip``, ``protocol``, ``ports``, ``tcp flags``
14
+
- Support for ``ip``, ``protocol``, ``ports``, ``tcp flags``, ``interfaces``
17
15
- Support for ``connection tracking``
18
16
- Support for bpf ``TC`` and ``XDP`` mode
19
17
@@ -25,6 +23,8 @@ Detailed supported parameters
25
23
- ``--sport`` source port
26
24
- ``--dport`` destination port
27
25
- ``--tcpflags`` tcp flags
26
+
- ``-i`` input interface
27
+
- ``-o`` output interface
28
28
- ``-m conntrack --ctstate`` conntrack module
29
29
30
30
Detailed supported targets
@@ -46,20 +46,40 @@ Limitations
46
46
^^^^^^^^^^^
47
47
48
48
- No support for multiple chains
49
-
- No support for ``-i`` ``-o`` interfaces
50
49
- No support for ``SNAT``, ``DNAT``, ``MASQUESRADE``
51
50
- ``-S`` ``-L`` generate an output slightly different from iptables
52
51
53
52
Install
54
53
-------
55
54
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
+
57
71
::
58
72
59
-
cd polycube/build/
60
-
cmake .. -DENABLE_PCN_IPTABLES=ON
61
-
make && make install
62
73
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
63
83
64
84
Run
65
85
---
@@ -128,5 +148,20 @@ XDP mode
128
148
Limitations
129
149
^^^^^^^^^^^
130
150
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.
`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.
3
2
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