Debian Codegraph @

docs/config/rule/statement.md

raw
1 # Statements
2
3
4 ## accept, drop, reject
5
6 Accepts, drops or rejects traffic. Default statement for single rule is to
7 accept matched traffic: `tcp 443` is equal to `tcp 443 accept`.
8
9 You should always add explicit final statement as last rule to every
10 [zone-zone](../section/zonezone.md) section in your configuration.
11
12 * For incoming traffic from internet to localhost/intranet the recommended
13 statement is `drop log`.
14 * For outgoing traffic from localhost/intranet to internet the recommended
15 statement is `reject log`.
16
17
18 ## continue
19
20 Continues to next rule. This is used mostly to debug rules. For example rule
21 `saddr 10.0.0.4 counter log continue` counts and logs traffic from 10.0.0.4 and
22 continues to next rule.
23
24
25 ## return
26
27 This is a special statement to return from current nftables chain to caller
28 chain. Not normally used.
29
30
31 ## masquerade, snat, dnat, snat_prefix, dnat_prefix
32
33 These statements are used in `snat` and `dnat`
34 [sections](../section/snat.md) to mangle traffic source or destination
35 IP address. See that page for description and examples.
36
37
38 ## notrack
39
40 Mark matching packet to not be added to conntrack. This has to be done early
41 in `prerouting` section. For example high load DNS server can use this for
42 DNS queries.
43
44 Example:
45
46 ```
47 # Incoming traffic
48 prerouting filter raw {
49 domain notrack # dport
50 tcp sport 53 notrack # sport
51 udp sport 53 notrack
52 }
53
54 # Locally created traffic
55 output filter raw {
56 domain notrack
57 tcp sport 53 notrack
58 udp sport 53 notrack
59 }
60 ```
61
62
63 ## queue
64
65 Forward packet to userspace for example for IPS/IDS inspection. Optional flags
66 and target can be specified. Example:
67
68 ```
69 forward {
70 # Forward all packets to userspace for IPS inspection
71 queue flags fanout,bypass to 3-5
72
73 # Forward matching packets only
74 iifname eth0 oifname eth1 queue
75 }
76 ```
77
78
79 ## nftrace
80
81 Enable nftrace ruleset debugging for matching packets. This is usually done
82 in `input`, `output` or `forward` section. Tracing events can be viewed with
83 `nft monitor trace` command.
84
85 Example:
86
87 ```
88 input {
89 # Trace all incoming packets - generates lot of trace!
90 nftrace
91 }
92
93 forward {
94 # Trace all forwarded ssh packets
95 ssh nftrace
96 }
97 ```