Wolfspyre Labs 🐺🔥🔬/ Our Guides/ CoreDNS @ Wolfspyre Labs/ 🏗️ Setting Up CoreDNS/ Pi4 Soup to nuts/ ④ Building CoreDNS/ ④ Building CoreDNS ⇦ ⇦ ⇦ Back to Base config ③ Here, We get CoreDNS built # ⑤ Deploy and configure CoreDNS ⇨ ⇨ ⇨ Build Packages Unbound Libs Setup Golang [Build CoreDNS](#buildcoredns} 🐾 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 linux 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). Warning 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): 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 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. root@coredns-02:~# go version go version go1.19 linux/arm64 mac Build CoreDNS #Building CoreDNS is pretty simple, once all the pieces are in play. First we’ll clone the repo # get the coreDNS code local 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 # get the coreDNS code local 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… splitting CoreDNS plugin.cfg file wolf@coredns: /usr/src/coredns$ wc -l plugin.cfg 72 plugin.cfg wolf@coredns: /usr/src/coredns$ head -53 plugin.cfg |tail -1 template:template wolf@coredns: /usr/src/coredns$ 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: CoreDNS Plugin.cfg manipulation wolf@coredns: /usr/src/coredns$ cat plugin.cfg > plugin.cfg_orig wolf@coredns: /usr/src/coredns$ head -53 plugin.cfg >wpl_plugin.cfg wolf@coredns: /usr/src/coredns$ 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 wolf@coredns: /usr/src/coredns$ tail -19 plugin.cfg >> wpl_plugin.cfg wolf@coredns: /usr/src/coredns$ cat wpl_plugin.cfg > plugin.cfg SWEET! plugin.cfg ↕ CoreDNS Plugin.cfg 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… Let’s build this puppy! cd /usr/src/coredns; make clean;CGO_ENABLED=1 make Yeah…. I know… Somewhat anticlimactic. 🐾 ⇦ ⇦ ⇦ Back to Base config ③ ⑤ Deploy and configure CoreDNS ⇨ ⇨ ⇨ https://go.dev/dl/ ↩︎