A local coredns docker-compose stack. I use it mainly to block ads and cache DNS on my machines.
Docker/Podman and docker-compose installed and running. I use a rootless docker on my daily operations but it should work with docker daemon too.
- Clone the repository to a local directory - Personally I prefer to clone it directly to
/etc/coredns
; - Enter in the directory and run the command
docker compose up -d
; - [SYSTEMD USERS ONLY] Update the file
/etc/systemd/resolved.conf
DNS Configuration as following:
[Resolve]
DNS=127.0.0.253
-
Run
systemctl restart systemd-resolved
; -
Check if the changes were applied by running the command
systemctl-resolve --status
:Global Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Current DNS Server: 127.0.0.253 DNS Servers: 127.0.0.253 127.0.0.253
a. You can see the queries issued by checking the logs of the coredns container using the command docker logs coredns
.
b. There are some nice metrics available at http://127.0.0.1:9153/metrics
.
If you're like me and prefer to use the DNS to block ads and other stuff, you can write any hosts that you want to block into the hosts file that lies in the same directory as the docker-compose.
My preferred deny list is the
StevenBlack/hosts
lists that can be downloaded fromhttps://github.com/StevenBlack/hosts
.
Author: Gabriel Abdalla Cavalcante Silva (gabriel.cavalcante88 at gmail.com)