Debian Codegraph @

docs/config/basic.md

raw
1 # Basics
2
3 ## Configuration files
4
5 Foomuuri reads configuration files from `/etc/foomuuri/*.conf` in alphabetical
6 order, including all sub directories. Foomuuri also reads static configuration
7 from `/usr/share/foomuuri/*.conf` which can be overwritten in `/etc/foomuuri`.
8
9 Configuration can be written to single or multiple files. Following is just a
10 recommendation, not a rule:
11
12 * Simple configuration (less than 200 lines) in single
13 `/etc/foomuuri/foomuuri.conf` file.
14 * Large configuration should be split to `/etc/foomuuri/foomuuri.conf`,
15 `/etc/foomuuri/localhost.conf` , `/etc/foomuuri/public.conf` etc. files.
16 * `foomuuri.conf` contains everything but zone-zone sections.
17 * `localhost.conf` contains all xxx-localhost sections (or localhost-xxx).
18 * `public.conf` contains all xxx-public sections (or public-xxx).
19 * Subdirectories can be used, for example
20 `/etc/foomuuri/zones.d/localhost.conf`.
21 * Very large configuration could be split to multiple `localhost-public.conf`
22 etc. files, containing only single zone-zone section per file.
23
24 Raw `nftables` rules can be written to `/etc/foomuuri/*.nft` and they will be
25 included to generated ruleset.
26
27 ## Zone names
28
29 Following zones names are recommended, but you can use whatever you want to.
30
31 ### localhost
32
33 `localhost` is the zone name for the computer running Foomuuri, similar to
34 "localhost" in hostnames. If you decide to use some other name then you must
35 configure it in [foomuuri { localhost_zone }](section/foomuuri.md) section.
36
37 ### public
38
39 `public` is the default external network zone, similar to "internet". Basic
40 host firewall has only `localhost` and `public` zones. If you decide to use
41 some other name then you should also configure it in
42 [foomuuri { dbus_zone }](section/foomuuri.md) section.
43
44 `public` is for use in public areas. You do not trust the other computers on
45 networks to not harm your computer.
46
47 ### home
48
49 Similar to `public`, but for use in home areas. You mostly trust the other
50 computers on networks to not harm your computer.
51
52 ### work
53
54 Similar to `public`, but for use in work areas. You mostly trust the other
55 computers on networks to not harm your computer.
56
57 ### internal
58
59 `internal` is your internal network ("intranet") zone for router firewall
60 configurations. Remote connections from `public` should not be allowed to
61 `internal`.
62
63 ### dmz
64
65 Demilitarized zone is publicly-accessible part of your internal network.
66 Only selected incoming connections should be accepted from `public` to `dmz`,
67 for example `https`.
68
69 ### vpn
70
71 IPsec and similar VPN traffic.
72
73
74 ## Miscellaneous
75
76 Comments can be written as `# comment`.
77
78 Long line can be split to multiple lines by adding `\` to end of line.
79
80 Multiple words can be combined to single word by writing them in quotes.
81 For example `ssh accept log "accept ssh for testing"` will accept SSH
82 traffic with log message `accept ssh for testing`.
83
84 Output from external command can be used to generate rules. It can return
85 single line, multiple lines or part of line. Syntax is
86 `$(shell command to run with parameters)`. Command is run with shell so pipes
87 and `;` will work. Be careful to run only trusted commands. `$(shell)` is
88 processed before [macro](section/macro.md) expansion.
89
90 Example:
91
92 ```
93 # This is a comment
94
95 macro {
96 # Define local_port_range macro by reading correct value from /proc file
97 local_port_range $(shell sed s/\\t/-/ < /proc/sys/net/ipv4/ip_local_port_range)
98 }
99
100 localhost-public {
101 ssh # This is a comment
102 smtp \
103 daddr 192.0.2.32 # Allow SMTP to single IP
104 }
105
106 public-localhost {
107 tcp local_port_range # Allow TCP to ports 32768-60999 (default range)
108 }
109 ```
110
111 Command to run can not contain `)` character. For such complex commands it's
112 better to create shell script and call that:
113
114 ```
115 macro {
116 mymacro $(shell /etc/foomuuri/mymacro.sh parameters)
117 }
118 ```