How to install CoreDNS on Ubuntu Server Latest
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.
Prerequisites
Before proceeding with the installation, make sure your Ubuntu Server is updated and upgraded to the latest version.
sudo apt update
sudo apt upgrade
Step 1: Install CoreDNS
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.tgzExtract the downloaded package by running the following command:
tar xvf coredns_1.8.3_linux_amd64.tgzMove the extracted binary to
/usr/local/bindirectory.sudo mv coredns /usr/local/bin/
Step 2: Configure CoreDNS
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
Corefilein the/etc/corednsdirectory.sudo mkdir /etc/coredns sudo nano /etc/coredns/CorefileAdd 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.
Step 3: Start CoreDNS
To start CoreDNS as a system service, you need to create a systemd unit file.
sudo nano /etc/systemd/system/coredns.serviceAdd 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.targetSave and exit the file.
Reload systemd configuration.
sudo systemctl daemon-reloadStart CoreDNS.
sudo systemctl start corednsCheck the status of CoreDNS.
sudo systemctl status corednsThe output should show that CoreDNS is active and running.
Conclusion
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.