Debian Codegraph @

docs/config/section/macro.md

raw
1 # macro
2
3 Instead of writing rule `tcp 443` it is easier and more readable to use rule
4 `https`. These alias names are called macros. Macro can be used in any part
5 of rule you want to, defining rule fully or partially.
6
7 ```
8 macro {
9 # Define service as macro
10 smtp tcp 25
11 https tcp 443; udp 443
12 googlemeet udp 3478 19302-19309; https
13
14 # Define rate limit as macro
15 ssh_rate saddr_rate "5/minute burst 5"
16
17 # Long macro can be split to multiple lines with "+" (append to previous) or
18 # "\" (continue in next line).
19 # Warning: Using "+" or "\" does not add ";". You must add it yourself when
20 # needed.
21 good_hosts 10.0.0.1 fd00:f00::1
22 good_hosts + 10.0.0.2 fd00:f00::2
23 another 10.0.0.3 \
24 10.0.0.4
25 semicolon http
26 semicolon + ; https
27 }
28 ```
29
30 You can use above macros in other sections:
31
32 ```
33 localhost-public {
34 https daddr good_hosts # Allow https to specific IP addresses
35 tcp 23 daddr good_hosts # Allow TCP 23 to specific IP addresses
36 https reject # Reject all other https traffic
37 googlemeet # Allow Google Meet to everywhere
38 }
39
40 public-localhost {
41 ssh ssh_rate # Allow incoming ssh with rate limit
42 }
43 ```
44
45 Macro can include other macros, as `googlemeet` in above example does.
46
47 Using `;` in macro splits it to multiple rule lines. You must use it
48 when macro contains two different rules, like `tcp 443` and `udp 443` in
49 `https` macro, or `udp XXX` and `https` in `googlemeet` macro.
50 Do not use it when creating list of items (IP addresses for example)
51 for single rule, like in `good_hosts`.
52
53 All
54 [known macros](https://github.com/FoobarOy/foomuuri/blob/main/etc/default.services.conf)
55 can be listed with `foomuuri macro list` command.
56
57 Macro expansion can be skipped by writing word in quotes. For example `"ssh"`
58 is kept as `ssh` and not expanded to `tcp 22`.
59
60 For safety reasons macro expansion is not done in `zone` or `foomuuri`
61 sections.