Skip to content

Commit a301cc9

Browse files
committed
Add Blocker to the external plugins list
1 parent e7d068e commit a301cc9

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

content/explugins/blocker.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
+++
2+
title = "blocker"
3+
description = "*blocker* - Domain blocker plugin for CoreDNS."
4+
weight = 10
5+
tags = [ "plugin" , "dns" ]
6+
categories = [ "plugin", "external" ]
7+
date = "2025-04-13T11:58:24+09:00"
8+
repo = "https://github.com/icyflame/blocker"
9+
home = "https://github.com/icyflame/blocker/blob/master/README.org"
10+
+++
11+
12+
## Description
13+
14+
The blocker plugin blocks a list of domains provided in a file written using the AdBlock Plus syntax
15+
format. The list of blocked domains is loaded into memory at start-up, and periodically after that.
16+
17+
## Syntax
18+
19+
~~~ txt
20+
blocker path-to-blocklist-file refresh-interval file-syntax empty-response-type
21+
~~~
22+
23+
1. `path-to-blocklist-file`: Absolute path to a file that contains the list of blocked domains
24+
2. `refresh-interval`: Interval after which the file is read from disk and loaded into memory
25+
periodically. Duration must be a string which can be parsed by Go's
26+
[`time.ParseDuration`](https://pkg.go.dev/time#ParseDuration).
27+
3. `file-syntax`: One of either `hosts` or `abp`. `hosts` files have a list of blocked domains,
28+
which will be blocked by exact match. `abp` syntax supports prefixes and multiple subdmoains
29+
using a single line in the file
30+
4. `empty-response-type`: One of either `empty` or `nxdomain`. `empty` will return `0.0.0.0` or `::`
31+
as the response when a DNS query for a blocked domain is made. `nxdomain` will return a
32+
non-existent domain name response for blocked domains.
33+
34+
## Metadata
35+
36+
This plugin exports the metadata key `blocker/request-blocked`. The value of this key will be `YES`
37+
when a domain is blocked and `NO` in all other cases.
38+
39+
If the `metadata` plugin is enabled, then this key can be added to the log line for each query using
40+
the `log` plugin:
41+
42+
``` corefile
43+
.:53 {
44+
metadata
45+
46+
log . "{common} {/blocker/request-blocked}"
47+
48+
blocker /home/user/blocklist_file 1h abp empty
49+
50+
forward . 1.1.1.1
51+
}
52+
```
53+
54+
## Examples
55+
56+
In this configuration, we block domains that are listed in the `/home/user/blocklist.abp` file and
57+
send an empty response (`0.0.0.0`) when domains in this list are quiered. This file will be reloaded
58+
from disk into memory every hour after start-up:
59+
60+
``` corefile
61+
. {
62+
blocker /home/user/blocklist.abp 1h abp empty
63+
64+
forward . 1.1.1.1
65+
}
66+
```

0 commit comments

Comments
 (0)