CoreDNS is a DNS server that can serve as an authoritative DNS server, a recursive DNS resolver, and a DNS proxy. In this tutorial, we will show you how to install CoreDNS on Ubuntu Server latest.
Before proceeding with the installation, make sure your Ubuntu Server is updated and upgraded to the latest version.
sudo apt update
sudo apt upgrade
First, download CoreDNS by running the following command:
wget https://github.com/coredns/coredns/releases/download/v1.8.3/coredns_1.8.3_linux_amd64.tgz
Extract the downloaded package by running the following command:
tar xvf coredns_1.8.3_linux_amd64.tgz
Move the extracted binary to /usr/local/bin
directory.
sudo mv coredns /usr/local/bin/
Next, you need to configure CoreDNS to serve DNS requests. You can use the default configuration file provided by CoreDNS or create your own configuration file.
Create a file named Corefile
in the /etc/coredns
directory.
sudo mkdir /etc/coredns
sudo nano /etc/coredns/Corefile
Add the following configuration to Corefile
:
.:53 {
log
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
forward . /etc/resolv.conf
cache 30
tls_cert_path /path/to/tls.crt
tls_key_path /path/to/tls.key
}
This configuration enables CoreDNS to serve DNS requests and provides some additional functionality such as logging, health checks, and caching.
Save and exit the file.
To start CoreDNS as a system service, you need to create a systemd unit file.
sudo nano /etc/systemd/system/coredns.service
Add the following configuration to coredns.service
:
[Unit]
Description=CoreDNS DNS Server
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/coredns -conf /etc/coredns/Corefile
[Install]
WantedBy=multi-user.target
Save and exit the file.
Reload systemd configuration.
sudo systemctl daemon-reload
Start CoreDNS.
sudo systemctl start coredns
Check the status of CoreDNS.
sudo systemctl status coredns
The output should show that CoreDNS is active and running.
You have successfully installed and configured CoreDNS on Ubuntu Server latest. You can now use it as a DNS resolver and proxy for your applications.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!