Skip to content

Commit 6a4a994

Browse files
committed
Update DNS cache page
Signed-off-by: DL6ER <[email protected]>
1 parent a94594a commit 6a4a994

File tree

5 files changed

+70
-77
lines changed

5 files changed

+70
-77
lines changed

β€Ždocs/api/dns/blocking.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- `GET /api/dns/blocking`
66

77
<!-- markdownlint-disable code-block-style -->
8-
???+ example "Request"
8+
???+ example "πŸ”“ Request"
99

1010
=== "cURL"
1111

@@ -18,7 +18,7 @@
1818
``` python
1919
import requests
2020

21-
url = 'http://pi.hole/api/dns/blocking'
21+
url = 'http://pi.hole:8080/api/dns/blocking'
2222
response = requests.get(url)
2323

2424
print(response.json())
@@ -92,7 +92,7 @@
9292
import requests
9393

9494
sid = '<valid session id>'
95-
url = 'http://pi.hole/api/dns/blocking'
95+
url = 'http://pi.hole:8080/api/dns/blocking'
9696
data = {"blocking": False, "delay": 30, "sid": sid}
9797

9898
response = requests.put(url, json=data)

β€Ždocs/api/dns/cache.md

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
# DNS - Cache Info
22

3-
## Obtain information about Pi-hole's DNS cache
3+
`pihole-FTL` offers an efficient DNS cache that helps speed up your Internet experience. This DNS cache is part of the embedded `dnsmasq` server. Setting the cache size to zero disables caching. The DNS TTL value is used for determining the caching period. `pihole-FTL` clears its cache on receiving `SIGHUP`.
4+
5+
<!-- markdownlint-disable code-block-style -->
6+
!!! warning Some warning about the DNS cache size
7+
**There is no benefit in increasing this number *unless* the number of DNS cache evictions is greater than zero.**
8+
9+
A larger cache *will* consume more memory on your node, leaving less memory available for other caches of your Pi-hole. If you push this number to the extremes, it may even be that your Pi-hole gets short on memory and does not operate as expected.
10+
11+
You can not reduce the cache size below `150` when DNSSEC is enabled because the DNSSEC validation process uses the cache.
12+
<!-- markdownlint-enable code-block-style -->
13+
14+
### Cache metrics
15+
16+
The Settings page (System panel, FTL table) gives live information about the cache usage.
17+
18+
#### DNS cache size
19+
20+
Size of the DNS domain cache, defaulting to 10,000 entries. It is the number of entries that can be actively cached at the same time.
21+
This information may also be queried using `dig +short chaos txt cachesize.bind`
22+
23+
The cache size is set in `/etc/dnsmasq.d/01-pihole.conf`. However, note that this setting does not survive Pi-hole updates. If you want to change the cache size permanently, add a setting
24+
25+
``` plain
26+
CACHE_SIZE=12345
27+
```
28+
29+
in `/etc/pihole/setupVars.conf` and run `pihole -r` (Repair) to get the cache size changed for you automatically.
30+
31+
#### DNS cache insertions
32+
33+
Number of total insertions into the cache. This number can be substantially larger than DNS cache size as expiring cache entries naturally make room for new insertions over time. Each lookup with a non-zero TTL will be cached.
34+
35+
This information may also be queried using `dig +short chaos txt insertions.bind`
36+
37+
#### DNS cache evictions
38+
39+
The number of cache entries that had to be removed although the corresponding entries were **not** expired. Old cache entries get removed if the cache is full to make space for more recent domains. The cache size should be increased when this number is larger than zero.
40+
41+
This information may also be queried using `dig +short chaos txt evictions.bind`
42+
43+
44+
## Obtain information about Pi-hole's DNS cache through the API
445

546
- `GET /api/dns/cache`
647

@@ -19,7 +60,7 @@
1960
``` python
2061
import requests
2162

22-
url = 'http://pi.hole/api/dns/cacheinfo'
63+
url = 'http://pi.hole:8080/api/dns/cacheinfo'
2364
sid = '<valid session id>'
2465
data = {"sid": sid}
2566

@@ -39,7 +80,7 @@
3980
``` json
4081
{
4182
"cache_size": 10000,
42-
"cache_inserted": 509,
83+
"cache_inserted": 2616,
4384
"cache_evicted": 0
4485
}
4586
```
@@ -51,23 +92,15 @@
5192
**Fields**
5293

5394
??? info "DNS cache size (`"cache_size": number`)"
54-
Size of the DNS domain cache, defaulting to 10,000 entries. You typically specify this number directly in `/etc/dnsmasq.d/01-pihole.conf`. It is the number of entries that can be actively cached at the same time. There is no benefit in enlarging this number *except* if the DNS cache evictions count is larger than zero.
55-
56-
This information may also be queried using `#!bash dig +short chaos txt cachesize.bind`
95+
See above.
5796

5897
??? info "DNS cache insertions (`"cache_inserted": number`)"
5998

60-
Number of total insertions into the cache. This number can be substantially larger than DNS cache size as expiring cache entries naturally make room for new insertions over time. Each lookup with a non-zero TTL will be cached.
61-
62-
This information may also be queried using `#!bash dig +short chaos txt insertions.bind`
99+
See above.
63100

64101
??? info "DNS cache evictions (`"cache_evicted": number`)"
65102

66-
The number of cache entries that had to be removed although the corresponding entries were **not** expired. Old cache entries get removed if the cache is full to make space for more recent domains.
67-
68-
The cache size should be increased when the number of evicted cache entries is larger than zero.
69-
70-
This information may also be queried using `#!bash dig +short chaos txt evictions.bind`
103+
See above.
71104

72105
<!-- markdownlint-enable code-block-style -->
73106

β€Ždocs/api/domainlists.md renamed to β€Ždocs/api/domains.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
``` python
2828
import requests
2929

30-
url = 'http://pi.hole/api/domains'
30+
url = 'http://pi.hole:8080/api/domains'
3131
sid = '<valid session id>'
3232
data = {"sid": sid}
3333

@@ -165,7 +165,7 @@
165165
import requests
166166

167167
domain = 'allowed.com'
168-
url = 'http://pi.hole/api/domains/allow/exact/' + domain
168+
url = 'http://pi.hole:8080/api/domains/allow/exact/' + domain
169169
sid = '<valid session id>'
170170
data = {"sid": sid}
171171

@@ -246,7 +246,7 @@
246246
import requests
247247

248248
domain = "allowed2.com"
249-
url = 'http://pi.hole/api/domains/allow/exact/' + domain
249+
url = 'http://pi.hole:8080/api/domains/allow/exact/' + domain
250250
sid = '<valid session id>'
251251
data = {
252252
"enabled": True,
@@ -341,7 +341,7 @@
341341
import requests
342342

343343
domain = "allowed2.com"
344-
url = 'http://pi.hole/api/domains/allow/regex/' + domain
344+
url = 'http://pi.hole:8080/api/domains/allow/regex/' + domain
345345
sid = '<valid session id>'
346346
data = {
347347
"oldtype": "allow/exact",
@@ -429,7 +429,7 @@
429429
import requests
430430

431431
domain = 'allowed2.com'
432-
url = 'http://pi.hole/api/domains/allow/exact/' + domain
432+
url = 'http://pi.hole:8080/api/domains/allow/exact/' + domain
433433
sid = '<valid session id>'
434434
data = {"sid": sid}
435435

@@ -445,7 +445,7 @@
445445
import urllib
446446

447447
regex = urllib.parse.quote("(^|\\.)facebook.com$")
448-
url = 'http://pi.hole/api/domains/allow/exact/' + regex
448+
url = 'http://pi.hole:8080/api/domains/allow/exact/' + regex
449449
sid = '<valid session id>'
450450
data = {"sid": sid}
451451

β€Ždocs/ftldns/dns-cache.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

β€Žmkdocs.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,21 @@ nav:
8888
- 'Examples': database/gravity/example.md
8989
- 'Pi-hole API':
9090
- 'Overview': api/index.md
91-
- 'πŸ”‘ Authentication': api/auth.md
91+
- 'Authentication': api/auth.md
9292
- 'DNS':
93-
- 'πŸ”“ Blocking status': api/dns/blocking.md
94-
- 'πŸ”’ Cache information': api/dns/cache.md
95-
- 'πŸ”’ Domain Lists': api/domainlists.md
96-
- 'πŸ”’ Network': api/tbd.md
97-
- 'πŸ”’ Logs': api/tbd.md
93+
- 'Blocking status': api/dns/blocking.md
94+
- 'Cache information': api/dns/cache.md
95+
- 'Domains': api/domains.md
96+
- 'Network': api/tbd.md
97+
- 'Logs': api/tbd.md
9898
- 'Statistics':
99-
- 'πŸ”“ Summary': api/tbd.md
100-
- 'πŸ”“ Over time': api/tbd.md
101-
- 'πŸ”’ Upstreams': api/tbd.md
102-
- 'πŸ”’ Top Items': api/tbd.md
103-
- 'πŸ”’ History': api/tbd.md
104-
- 'πŸ”“ Version': api/tbd.md
105-
- 'πŸ”’ Settings': api/tbd.md
99+
- 'Summary': api/tbd.md
100+
- 'Over time': api/tbd.md
101+
- 'Upstreams': api/tbd.md
102+
- 'Top Items': api/tbd.md
103+
- 'History': api/tbd.md
104+
- 'Version': api/tbd.md
105+
- 'Settings': api/tbd.md
106106
- 'FTLDNS':
107107
- 'Overview': ftldns/index.md
108108
- 'Configuration': ftldns/configfile.md
@@ -187,6 +187,7 @@ plugins:
187187
redirect_maps:
188188
'ftldns/database.md': database/index.md
189189
'ftldns/regex/index.md': ftldns/regex/overview.md
190+
'ftldns/dns-cache/index.md': api/dns/cache.md
190191
'main/presentations.md': index.md
191192
'main/prerequesites.md': main/prerequisites.md
192193
'guides/unbound.md': guides/dns/unbound.md

0 commit comments

Comments
Β (0)