How to Install CoreDNS on OpenBSD

CoreDNS is a DNS server that can be used as an alternative to traditional DNS servers. In this tutorial, we will walk you through the installation process of CoreDNS on OpenBSD.

Prerequisites

Before installing CoreDNS, make sure your OpenBSD system is up to date.

Step 1: Download CoreDNS

First, navigate to https://coredns.io/ and download the latest version of CoreDNS.

You can either download the source code or pre-built binaries for OpenBSD from the website.

$ wget https://github.com/coredns/coredns/releases/download/v1.6.8/coredns_1.6.8_openbsd_amd64.tgz

Step 2: Extract the Archive

After downloading the archive, extract it to your preferred directory:

$ tar -xvf coredns_1.6.8_openbsd_amd64.tgz -C /usr/local/bin/

Step 3: Create the CoreDNS Configuration File

Next, we will create a configuration file for CoreDNS. Below is a simple configuration file you can use to get started:

.:53 {
    forward . 1.1.1.1 1.0.0.1
}

In this configuration file, we are forwarding all DNS requests to Cloudflare's DNS servers (1.1.1.1 and 1.0.0.1).

You can create this configuration file in your preferred text editor:

$ vi /etc/coredns/Corefile

Save and exit the file.

Step 4: Start CoreDNS

To start CoreDNS, run the following command:

$ coredns -conf /etc/coredns/Corefile

You should see a message indicating that CoreDNS is running:

.:53
2019-09-10T10:30:11.564-0700 [INFO] CoreDNS-1.6.8
2019-09-10T10:30:11.564-0700 [INFO] linux/amd64, go1.12.9, 6b56a9c
CoreDNS-1.6.8

Step 5: Verify CoreDNS is Running

To verify that CoreDNS is running, run the following command:

$ dig @localhost example.com

You should see a response from CoreDNS:

; <<>> DiG 9.16.6 <<>> @localhost example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63738
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com.                    IN      A

;; ANSWER SECTION:
example.com.             518     IN      A       93.184.216.34

;; Query time: 21 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Sep 10 10:37:42 PDT 2019
;; MSG SIZE  rcvd: 56

Congratulations! You have successfully installed and configured CoreDNS on OpenBSD.

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!