2021-03-05 08:02:00 +01:00
# Installation
You can choose one of the following installation options:
* Run as standalone binary
* Run as docker container
## Prepare your configuration
2024-03-12 23:15:30 +01:00
Blocky supports single or multiple YAML files as configuration. Create new `config.yml` with your configuration
(see [Configuration ](configuration.md ) for more details and all configuration options).
2021-03-05 08:02:00 +01:00
Simple configuration file, which enables only basic features:
```yaml
upstream:
2021-06-25 14:27:28 +02:00
default:
2021-03-05 08:02:00 +01:00
- 46.182.19.48
- 80.241.218.68
- tcp-tls:fdns1.dismail.de:853
- https://dns.digitale-gesellschaft.ch/dns-query
blocking:
2024-04-08 19:09:51 +02:00
denylists:
2021-03-05 08:02:00 +01:00
ads:
- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
clientGroupsBlock:
default:
- ads
2023-06-13 16:15:16 +02:00
ports:
dns: 53
http: 4000
2021-03-05 08:02:00 +01:00
```
## Run as standalone binary
Download the binary file from [GitHub ](https://github.com/0xERR0R/blocky/releases ) for your architecture and
run `./blocky --config config.yml` .
!!! warning
2024-03-12 23:15:30 +01:00
Please be aware, if you want to use port 53 or 953 on Linux you should add `CAP_NET_BIND_SERVICE` capability
to the binary with `setcap 'cap_net_bind_service=+ep' ./blocky` , or run as root (not recommended).
2021-03-05 08:02:00 +01:00
## Run with docker
### Alternative registry
2024-03-12 23:15:30 +01:00
Blocky docker images are deployed to DockerHub (`spx01/blocky`) and GitHub Container Registry (`ghcr.io/0xerr0r/blocky`).
2021-03-05 08:02:00 +01:00
2022-03-31 22:50:20 +02:00
### Parameters
2024-03-12 23:15:30 +01:00
You can define the location of the config file in the container with environment variable `BLOCKY_CONFIG_FILE` .
Default value is `/app/config.yml` .
2022-03-31 22:50:20 +02:00
2021-03-05 08:02:00 +01:00
### Docker from command line
Execute following command from the command line:
2024-03-12 23:15:30 +01:00
```sh
2021-03-05 08:02:00 +01:00
docker run --name blocky -v /path/to/config.yml:/app/config.yml -p 4000:4000 -p 53:53/udp spx01/blocky
```
### Run with docker-compose
Create following `docker-compose.yml` file
```yaml
version: "2.1"
services:
blocky:
image: spx01/blocky
container_name: blocky
restart: unless-stopped
2022-11-24 21:39:58 +01:00
# Optional the instance hostname for logging purpose
hostname: blocky-hostname
2021-03-05 08:02:00 +01:00
ports:
- "53:53/tcp"
- "53:53/udp"
- "4000:4000/tcp"
environment:
- TZ=Europe/Berlin # Optional to synchronize the log timestamp with host
volumes:
2022-11-24 21:39:58 +01:00
# Optional to synchronize the log timestamp with host
- /etc/localtime:/etc/localtime:ro
2021-03-05 08:02:00 +01:00
# config file
- ./config.yml:/app/config.yml
```
and start docker container with
2024-03-12 23:15:30 +01:00
```sh
2021-03-05 08:02:00 +01:00
docker-compose up -d
```
### Advanced setup
Following example shows, how to run blocky in a docker container and store query logs on a SAMBA share. Local black and
2024-04-08 19:09:51 +02:00
allowlists directories are mounted as volume. You can create own black or allowlists in these directories and define the
path like '/app/allowlists/allowlist.txt' in the config file.
2021-03-05 08:02:00 +01:00
!!! example
```yaml
version: "2.1"
services:
blocky:
image: spx01/blocky
container_name: blocky
restart: unless-stopped
ports:
- "53:53/tcp"
- "53:53/udp"
2024-03-12 23:15:30 +01:00
- "4000:4000/tcp" # Prometheus stats (if enabled)
2021-03-05 08:02:00 +01:00
environment:
- TZ=Europe/Berlin
volumes:
# config file
- ./config.yml:/app/config.yml
# write query logs in this volume
- queryLogs:/logs
2024-04-08 19:09:51 +02:00
# put your custom allow/denylists in these directories
- ./denylists:/app/denylists/
- ./allowlists:/app/allowlists/
2021-03-05 08:02:00 +01:00
volumes:
queryLogs:
driver: local
driver_opts:
type: cifs
o: username=USER,password=PASSWORD,rw
device: //NAS_HOSTNAME/blocky
```
2022-05-25 15:13:52 +02:00
#### Multiple configuration files
For complex setups, splitting the configuration between multiple YAML files might be desired. In this case, folder containing YAML files is passed on startup, Blocky will join all the files.
2024-03-12 23:15:30 +01:00
```sh
./blocky --config ./config/
```
2022-05-25 15:13:52 +02:00
!!! warning
2024-03-12 23:15:30 +01:00
Blocky simply joins the multiple YAML files. If an option (e.g. `upstream` ) is present in multiple files, the configuration will not load and start will fail.
2022-05-25 15:13:52 +02:00
2021-08-18 22:07:04 +02:00
## Other installation types
!!! warning
2024-03-12 23:13:23 +01:00
These projects are not associated with Blocky devs and are listed here for convenience.
2021-08-18 22:07:04 +02:00
2024-03-12 23:13:23 +01:00
### Arch Linux via AUR
2021-08-18 22:07:04 +02:00
See [https://aur.archlinux.org/packages/blocky/ ](https://aur.archlinux.org/packages/blocky/ )
2024-03-12 23:13:23 +01:00
### Alpine Linux
2021-08-18 22:07:04 +02:00
See [https://pkgs.alpinelinux.org/package/edge/testing/x86/blocky ](https://pkgs.alpinelinux.org/package/edge/testing/x86/blocky )
2024-03-12 23:13:23 +01:00
### CentOS/Debian/Fedora install script
2021-08-20 22:18:36 +02:00
See [https://github.com/m0zgen/blocky-installer ](https://github.com/m0zgen/blocky-installer )
2024-03-12 23:13:23 +01:00
### FreeBSD
2021-09-14 08:50:25 +02:00
See [https://www.freebsd.org/cgi/ports.cgi?query=blocky&stype=all ](https://www.freebsd.org/cgi/ports.cgi?query=blocky&stype=all )
2024-03-12 23:13:23 +01:00
### Gentoo
See the [Gentoo Wiki ](https://wiki.gentoo.org/wiki/Project:GURU/Information_for_End_Users ) to enable the GURU repository, then run `emerge net-dns/blocky` .
### NixOS
2024-01-30 12:58:02 +01:00
2024-03-12 23:13:23 +01:00
As `pkgs.blocky` and a module:
2024-01-30 12:58:02 +01:00
2024-03-12 23:13:23 +01:00
```nix
services.blocky = {
enable = true;
settings = {
# anything from config.yml
};
};
```
### macOS via Homebrew
2023-04-15 23:56:29 +02:00
See [https://formulae.brew.sh/formula/blocky ](https://formulae.brew.sh/formula/blocky )
2024-03-12 23:13:23 +01:00
### TrueNAS SCALE via TrueCharts
See [https://truecharts.org/charts/enterprise/blocky/ ](https://truecharts.org/charts/enterprise/blocky/ )
(TrueCharts is not an official TrueNAS project)
2024-03-12 23:15:00 +01:00
## Companion projects
!!! warning
These projects are not associated with Blocky devs and are listed here for convenience.
### Lists updater
[Blocky lists updater ](https://github.com/shizunge/blocky-lists-updater ) updates list related configuration without restarting blocky DNS.
### Web UI
[Blocky Frontend ](https://github.com/Mozart409/blocky-frontend ) provides a Web UI to control blocky.
See linked project for installation instructions.
2021-04-15 08:32:04 +02:00
--8< -- " docs / includes / abbreviations . md "