Debian Codegraph @

cmd/atomdns/handlers/acl/README.md

raw
1 # Name
2
3 _acl_ - enforces access control policies
4
5 # Description
6
7 With _acl_, users are able to block or filter suspicious DNS queries by configuring IP filter rule sets, i.e.
8 allowing authorized queries or blocking unauthorized queries.
9
10 When evaluating the rule sets, _acl_ uses the source IP adresss, unless the _ecs_ handler has added an address
11 to the context.
12
13 # Syntax
14
15 ```
16 acl {
17 ACTION [QTYPE|OPCODE]... [NET]...
18 ACTION CTX VALUE...
19 }
20 ```
21
22 - **ACTION** defines the way to deal with DNS queries matched by this rule. The default action is _allow_,
23 DNS query not matched by any rules will be allowed to continue. The following actions are defined:
24 - _allow_ forward the query to the next handler.
25 - _block_ stop the query and return a _refused_ response with the extended error (EDE) 'blocked'.
26 - _filter_ stop the query and returns _noerror_ response with the extended error (EDE) 'filtered'.
27 - _drop_ stop the query and don't send any reply.
28
29 - **QTYPE|OPCODE** is the query type, or opcode to match for the requests to be allowed or blocked. If
30 **QTYPE|OPCODE** is omitted it matches _all_ types and opcodes.
31
32 - **NET** is the source IP address requests to be allowed or blocked. Typical CIDR notation and single IP
33 addresses are supported.
34
35 - **CTX** must be used in the format `xxx/yyy`, i.e. two words seperated by a slash. The _geoip_ handler for
36 instance writes data under (among other) the key `geoip/city`, that can be used here. If the key does not
37 return any data it will considered a positive match and **ACTION** is performed.
38
39 - **VALUE** is the value to match **CTX** to. Again with the _geoip_ handler and using `Cambridge` here you
40 can have access control on a city level.
41
42 # Examples
43
44 Block everything.
45
46 ```conffile
47 . {
48 acl {
49 block
50 }
51 }
52 ```
53
54 Filter all DNS queries with record type A from 192.168.0.0/16.
55
56 ```conffile
57 . {
58 acl {
59 filter A 192.168.0.0/16
60 }
61 }
62 ```
63
64 Block all DNS queries from 192.168.0.0/16 except for 192.168.1.0/24.
65
66 ```conffile
67 . {
68 acl {
69 allow 192.168.1.0/24
70 block 192.168.0.0/16
71 }
72 }
73 ```
74
75 Drop all queries from Cambridge, this requires the _geoip_ handler to have populated the context for this
76 query. Allow all countries that are in the EU.
77
78 ```conffile
79 . {
80 acl {
81 block geoip/city Cambridge
82 allow geoip/country/eu true
83 }
84 }
85 ```
86
87 Drop opcode UPDATE for all but a few IP ranges.
88
89 ```conffile
90 . {
91 acl {
92 allow UPDATE 192.168.1.0/24
93 block UPDATE
94 }
95 }
96 ```
97
98 # Metrics
99
100 If monitoring is enabled (via the _metrics_ handler) then the following metrics are exported:
101
102 - `atomdns_acl_blocked_requests_total{zone, network, family}` - counter of DNS requests being blocked.
103 - `atomdns_acl_filtered_requests_total{zone, network, family}` - counter of DNS requests being filtered.
104 - `atomdns_acl_allowed_requests_total{zone, network, family}` - counter of DNS requests being allowed.
105 - `atomdns_acl_dropped_requests_total{zone, network, family}` - counter of DNS requests being dropped.
106
107 The `zone`,`network` and `family` labels are explained in the _metrics_ handler documentation. These metrics
108 follow the _global_'s metric `\N` setup, and as such should be multiplied by `N` to get the actual value.
109
110 # See Also
111
112 See atomdns-ecs(7) that can add a better source address.
113
114 # Bugs
115
116 _acl_ should also check TSIG and other signed messages, see https://codeberg.org/miekg/dns/issues/426 for the
117 remaining work.