CoreDNS is commonly deployed via container or as a standalone binary. Below are quick starts for both.
Download the latest CoreDNS release (adjust for your architecture):
curl -LO https://github.com/coredns/coredns/releases/download/v1.14.1/coredns_1.14.1_linux_amd64.tgz
Extract and install:
tar -xzf coredns_1.14.1_linux_amd64.tgz
sudo install -m 0755 coredns /usr/local/bin/coredns
Create a basic config file:
sudo mkdir -p /etc/coredns
sudo tee /etc/coredns/Corefile > /dev/null <<'EOF'
.:53 {
forward . 1.1.1.1 8.8.8.8
cache 30
log
}
EOF
Start CoreDNS:
sudo /usr/local/bin/coredns -conf /etc/coredns/Corefile
Follow the same steps as Debian/Ubuntu to install the CoreDNS binary and create a Corefile.
docker run --name coredns -p 53:53/udp -p 53:53/tcp \
-v $(pwd)/Corefile:/Corefile \
coredns/coredns:1.14.1 -conf /Corefile
Create a systemd unit to run CoreDNS in the background:
[Unit]
Description=CoreDNS DNS server
After=network.target
[Service]
ExecStart=/usr/local/bin/coredns -conf /etc/coredns/Corefile
Restart=on-failure
User=nobody
Group=nogroup
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl daemon-reload
sudo systemctl enable --now coredns
dig @127.0.0.1 example.com to test.