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

  1. 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
    
  2. Extract the downloaded package by running the following command:

    tar xvf coredns_1.8.3_linux_amd64.tgz
    
  3. Move the extracted binary to /usr/local/bin directory.

    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.

  1. Create a file named Corefile in the /etc/coredns directory.

    sudo mkdir /etc/coredns
    sudo nano /etc/coredns/Corefile
    
  2. 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.

  3. Save and exit the file.

Step 3: Start CoreDNS

  1. To start CoreDNS as a system service, you need to create a systemd unit file.

    sudo nano /etc/systemd/system/coredns.service
    
  2. 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
    
  3. Save and exit the file.

  4. Reload systemd configuration.

    sudo systemctl daemon-reload
    
  5. Start CoreDNS.

    sudo systemctl start coredns
    
  6. Check the status of CoreDNS.

    sudo systemctl status coredns
    

    The 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.

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!