blob: 8605ae009e0f700eb9980424aeccee567a9a1106 [file] [log] [blame]
Filip Pytlounab43e7b2015-10-06 16:28:32 +02001
2================
3iptables formula
4================
5
Filip Pytloun60062562016-07-27 14:41:15 +02006Iptables is used to set up, maintain, and inspect the tables of IPv4 packet
7filter rules in the Linux kernel. Several different tables may be defined.
8Each table contains a number of built-in chains and may also contain
9user-defined chains. Each chain is a list of rules which can match a set of
10packets. Each rule specifies what to do with a packet that matches. This is
11called a `target`, which may be a jump to a user-defined chain in the same
12table.
Filip Pytlounab43e7b2015-10-06 16:28:32 +020013
14Sample pillars
15==============
16
Filip Pytloun60062562016-07-27 14:41:15 +020017Most common rules - allow traffic on localhost, accept related,established and
18ping
Filip Pytlounab43e7b2015-10-06 16:28:32 +020019
20.. code-block:: yaml
21
Filip Pytloun60062562016-07-27 14:41:15 +020022 parametetrs:
23 iptables:
24 service:
Filip Pytlounab43e7b2015-10-06 16:28:32 +020025 chain:
26 INPUT:
Filip Pytloun60062562016-07-27 14:41:15 +020027 rules:
28 - in_interface: lo
Filip Pytlounab43e7b2015-10-06 16:28:32 +020029 jump: ACCEPT
Filip Pytloun60062562016-07-27 14:41:15 +020030 - connection_state: RELATED,ESTABLISHED
Filip Pytlounab43e7b2015-10-06 16:28:32 +020031 match: state
Filip Pytloun60062562016-07-27 14:41:15 +020032 jump: ACCEPT
33 - protocol: icmp
34 jump: ACCEPT
35
36Accept connections on port 22
37
38.. code-block:: yaml
39
40 parametetrs:
41 iptables:
42 service:
43 chain:
44 INPUT:
45 rules:
46 - destination_port: 22
Filip Pytlounab43e7b2015-10-06 16:28:32 +020047 protocol: tcp
Filip Pytloun60062562016-07-27 14:41:15 +020048 jump: ACCEPT
49
50Set drop policy on INPUT chain:
51
52.. code-block:: yaml
53
54 parametetrs:
55 iptables:
56 service:
57 chain:
58 INPUT:
59 policy: DROP
60
61Redirect privileged port 443 to 8081
62
63.. code-block:: yaml
64
65 parameters:
66 iptables:
67 service:
68 chain:
69 PREROUTING:
70 filter: nat
71 destination_port: 443
72 to_port: 8081
73 protocol: tcp
74 jump: REDIRECT
75
76Allow access from local network
77
78.. code-block:: yaml
79
80 parameters:
81 iptables:
82 service:
83 chain:
84 INPUT:
85 rules:
86 - protocol: tcp
87 destination_port: 22
88 source_network: 192.168.1.0/24
89 jump: ACCEPT
Filip Pytlounab43e7b2015-10-06 16:28:32 +020090
91Read more
92=========
93
94* http://docs.saltstack.com/en/latest/ref/states/all/salt.states.iptables.html
95* https://help.ubuntu.com/community/IptablesHowTo
96* http://wiki.centos.org/HowTos/Network/IPTables