The Hoof & Paw
DocsCategoriesTagsView the current conditions from the WolfspyreLabs WeatherstationToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Part 4 - Build CoreDNS

  • In Part One, We talked about hardware.
  • In Part Two, We got Ubuntu on your MicroSD card.
  • In Part Three We got everything set up to my personal liking, but ymmv.
Here in Part Four We get CoreDNS built β†’β†’β†’
  • In Part Five We deploy and configure CoreDNS
  • In Part Six We add a few odds & ends to make the host more durable
  • And in Part Seven We add the bits for the eInk display

Part Four


🐺πŸ”₯βš—οΈ

Package installations

Some Packages that we are going to need for building:

apt-get install make build-essential git

Package Dependencies for unbound

If you’re going to use the unbound resolver plugin, then you’ll need to install a few additional packages:
apt-get install libunbound-dev libunbound8 libevent-2.1-7

Setup Golang

You will be able to The main Download page on the golang site1

https://go.dev/dl/go1.19.linux-arm64.tar.gz https://go.dev/dl/go1.19.1.linux-arm64.tar.gz

https://go.dev/doc/install

  • Remove any previous Go installation by deleting the /usr/local/go folder (if it exists).

  • Extract the archive you just downloaded into /usr/local, creating a fresh Go tree in /usr/local/go:
    $ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.linux-arm64.tar.gz (You may need to run the command as root or through sudo).

Do not untar the archive into an existing /usr/local/go tree. This is known to produce broken Go installations.
  • Add /usr/local/go/bin to the PATH environment variable.
    • You can do this by adding the following line to your $HOME/.profile or /etc/profile (for a system-wide installation):
1
2
3
4
5
6

cat <<EOF>/etc/profile.d/golang-path.sh
#!/usr/bin/env bash
export PATH=$PATH:/usr/local/go/bin
EOF
chmod +x /etc/profile.d/golang-path.sh
-  Validate it's in your path by (after logging out and logging back in) inspecting the `$PATH` env var:  One way to skin the cat: `env|grep PATH` 
Note: Changes made to a profile file may not apply until the next time you log into your computer. To apply the changes immediately, just run the shell commands directly or execute them from the profile using a command such as source $HOME/.profile.
  • Verify that you’ve installed Go by opening a command prompt and typing the following command: $ go version Confirm that the command prints the installed version of Go.

    1
    2
    
      root@coredns-02:~# go version
      go version go1.19 linux/arm64
    

Build CoreDNS

Building CoreDNS is pretty simple, once all the pieces are in play.

First we’ll clone the repo

REPO=https://github.com/coredns/coredns.git
REPO=https://gitlab.wolfspyre.io/mirrored_repos/coredns/coredns.git
cd /usr/src && git clone ${REPO} && cd /usr/src/coredns

Next, we’ll make our plugin.cfg changes

cp plugin.cfg plugin.cfg.orig

figure out where to split the plugin

So… because the ordering of the plugins in the plugin.cfg file. Our additions fall just after the line containing template:template

wc -l plugin.cfg
72 plugin.cfg

head -53 plugin.cfg |tail -1
template:template

tail -20 plugin.cfg|head -1
template:template

So, we now know that in this version of CoreDNS, our changes should be injected between lines 53 and 54

so lets do that horribly real quick:

cat plugin.cfg > plugin.cfg_orig
head -53 plugin.cfg >wpl_plugin.cfg
cat <<EOF>>wpl_plugin.cfg
git:github.com/miekg/coredns-git
mdns:github.com/openshift/coredns-mdns
netbox:github.com/oz123/coredns-netbox-plugin
unbound:github.com/coredns/unbound
finalize:github.com/tmeckel/coredns-finalizer
records:github.com/coredns/records
EOF
tail -19 plugin.cfg  >> wpl_plugin.cfg
cat wpl_plugin.cfg > plugin.cfg

SWEET!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
metadata:metadata
geoip:geoip
cancel:cancel
tls:tls
reload:reload
nsid:nsid
bufsize:bufsize
root:root
bind:bind
debug:debug
trace:trace
ready:ready
health:health
pprof:pprof
prometheus:metrics
errors:errors
log:log
dnstap:dnstap
local:local
dns64:dns64
acl:acl
any:any
chaos:chaos
loadbalance:loadbalance
tsig:tsig
cache:cache
rewrite:rewrite
header:header
dnssec:dnssec
autopath:autopath
minimal:minimal
template:template
git:github.com/miekg/coredns-git
mdns:github.com/openshift/coredns-mdns
netbox:github.com/oz123/coredns-netbox-plugin
unbound:github.com/coredns/unbound
finalize:github.com/tmeckel/coredns-finalizer
records:github.com/coredns/records
transfer:transfer
hosts:hosts
route53:route53
azure:azure
clouddns:clouddns
k8s_external:k8s_external
kubernetes:kubernetes
file:file
auto:auto
secondary:secondary
etcd:etcd
loop:loop
forward:forward
grpc:grpc
erratic:erratic
whoami:whoami
on:github.com/coredns/caddy/onevent
sign:sign
view:view

so now we have our plugin file… populated with our changes… letas build this sucker!

cd /usr/src/coredns; make clean;CGO_ENABLED=1 make

Yeah…. I know… somewhat anticlimactic.

🐺πŸ”₯βš—οΈ