root/trunk/etcnet/docs/README.firewall

Revision 1151, 3.7 kB (checked in by pilot, 1 year ago)

+ /etc/net trunk has been pulled to the 0.9.3 release watermark

Line 
1 Following documentation is obsolete and should be rewritten. etcnet supports now
2 iptables, ip6tables and ebtables with basic support of profiles (by using
3 fw/type#profile and fw/options#profile)
4 ===================================================================================
5 Firewall support in /etc/net
6 1. Iptables configs structure
7
8 /etc/net/ifaces/default/options: You'd set CONFIG_FW to "yes" for firewall support
9 /etc/net/ifaces/default/fw/options: Some options for firewall (type, syntax,
10 default policy for chains)
11
12 /etc/net/ifaces/<IFACE>/fw/iptables:
13 modules: file with list of modules to load when firewall starting
14 syntax: file with syntax of firewall rules if you've enabled
15 IPTABLES_HUMAN_SYNTAX
16
17 filter: directory with chains for table filter
18    |
19    --INPUT: File with rules for chain INPUT
20    |
21    --FORWARD: File with rules for chain FORWARD
22    |
23    --OUTPUT: File with rules for chain OUTPUT
24  
25 nat: directory with chains for table nat
26    |
27    --PREROUTING: File with rules for chain PREROUTING
28    |
29    --POSTROUTING: File with rules for chain POSTROUTING
30    |
31    --OUTPUT: File with rules for chain OUTPUT
32    
33 mangle: directory with chains for table mangle
34    |
35    --PREROUTING: File with rules for chain PREROUTING
36    |
37    --INPUT: File with rules for chain INPUT
38    |
39    --FORWARD: File with rules for chain FORWARD
40    |
41    --OUTPUT: File with rules for chain OUTPUT
42    |
43    --POSTROUTING: File with rules for chain POSTROUTING
44
45 You can create your own chain by adding new file to directory. Chain name is
46 case-sensitive!
47
48 Each directory may contains special file "loadorder". In this case tables and
49 chains processed in order from this file (ony by one)
50
51 2. Rules syntax
52 Supported  two type of syntax:
53         - raw iptables syntax
54         - new "human" syntax a la ipfw
55        
56 If you've enabled IPTABLES_HUMAN_SYNTAX in fw/options, then you can use rules
57 like ipfw (see examples and syntax file)
58
59 In both types of syntax you'd not to include chain or table name to rule.
60
61 You can use environment variables and even run one-string commands by using $(cmd).
62 If there is now output from commnd rule will not be added (this can be used
63 for including some configs or files with functions).
64
65 System environment variable $NAME contains current interface name.
66
67 Comments in all files must begins with #
68
69 3. How it works
70
71 When you start service network:
72 interface "default":
73 - If CONFIG_FW is yes then go step 2 otherwise go out :)
74 - Apply chains policy before any interface start and before forwarding is enabled
75   sysctl
76 - Load all modules from first to last from "module" file if any
77 - Create all user-defined chains in all tables if any
78 - From each chain in each table read rules one by one, parse it (if IPTABLES_HUMAN_SYNTAX)
79   and pass it to iptables
80 each other interface:
81 - Do same work except chains policy
82
83 When you stop service network:
84  Do same work in case of start with some diffrences:
85 - All steps goes in reverse order
86 - If interface is not "default" then rules deleted one by one from last to first
87   otherwise chain just flushed
88 - Modules unloads from last to first
89 - Reset chains policy to ACCEPT
90
91 You don't need to have all configs for all interfaces. Default rules (in
92 virtual "default" interface directory) are enough to setup firewall.
93 But you can have and start some special firewall rules for given interface
94 or just for clean kernel rules tables (i.e. if you have down some interface
95 there is no reason to have hundreds of rules for it)
96
97 There is special script /sbin/fw which can manage firewall without restarting
98 interface. Just run: /sbin/fw default stop and your firewall will be stopped :)
99
100  Bugs and limitations
101 1. Syntax file is not completed. Some rules (especially with prefix "not") will
102 not work (you can patch syntax file)
103 2. Many other limitations :)
Note: See TracBrowser for help on using the browser.