Debian Codegraph @

docs/config/rule/misc.md

raw
1 # Miscellaneous Rules
2
3
4 ## szone, dzone, new_szone, new_dzone
5
6 These can be specified in [zonemap](../section/zonemap.md) section to match
7 original source or destination zone, and to change it to a new zone. These
8 are used to branch out some specific traffic to its own zone, for example
9 to split `vpn` and `public` (non-VPN) traffic.
10
11
12 ## helper
13
14 Linux kernel provides conntrack helper functionality to some services with
15 multiple ports, like `ftp` (tcp 21). You can enable this functionality by
16 appending `helper kernelname-port` after matcher. For example
17 `tcp 21 helper ftp-21`.
18
19 Linux has following helpers: `amanda, ftp, h323, irc, netbios_ns, pptp,
20 sane, sip, snmp, tftp`
21
22
23 ## mss
24
25 Sets maximum segment size (MSS clamping) to all traffic. Some connections,
26 like IPsec or PPPoE, might require this. Example:
27
28 ```
29 localhost-vpn {
30 mss 1390
31 ssh
32 reject log
33 }
34 ```
35
36 Special value `mss pmtu` can be used to calculate the value in runtime
37 based on what the routing cache has observed via Path MTU Discovery (PMTUD).
38 Example:
39
40 ```
41 forward { # internal-public
42 mss pmtu
43 }
44
45 input { # public-localhost
46 mss pmtu
47 }
48
49 output { # localhost-public
50 mss pmtu
51 }
52 ```
53
54
55 ## conntrack, -conntrack
56
57 Rules are processed after conntrack check (flag `conntrack`, default value).
58 Flag `-conntrack` can be added to process rule before conntrack. Conntrack
59 will accept established and related traffic so normal rule will see only new
60 traffic.
61
62 This can be used to count all traffic instead of new connections only, or
63 to accept traffic without adding it to conntrack. For example high load
64 DNS server might accept DNS traffic without conntrack.
65
66 Example:
67
68 ```
69 public-localhost {
70 # Count all incoming traffic
71 counter incoming_traffic continue -conntrack
72
73 # Count incoming HTTP(S) traffic in web server
74 tcp dport 80 443 counter web_traffic_in continue -conntrack
75 ...
76 }
77
78 localhost-public {
79 # Count outgoing HTTP(S) traffic in web server
80 tcp sport 80 443 counter web_traffic_out continue -conntrack
81 ...
82 }
83 ```
84
85
86 ## nft
87
88 Raw nftables rule can be written with `nft "raw rule here"`. For example,
89 `https` rule can be written as:
90
91 ```
92 public-localhost {
93 nft "tcp dport 443 accept"
94 nft "udp dport 443 accept"
95 ...
96 }
97 ```
98
99 `nft` can also be combined with matchers:
100
101 ```
102 # Jump to my-custom-chain for UDP traffic to ports 1000-2000
103 udp 1000-2000 nft "jump my-custom-chain"
104 ```
105
106 See [nftables web page](https://wiki.nftables.org/) for more information
107 about nftables syntax.