Skip to content

Instantly share code, notes, and snippets.

@gbrayut gbrayut/Corefile
Last active Aug 20, 2018

Embed
What would you like to do?
Coredns using Docker
home.arpa {
file config/home.arpa
prometheus # enable metrics
errors # show errors
log # enable query logs
}
#Start coredns instance using docker. Bind to DNS ports, map /opt/coredns to /config in container and use it's Corefile
docker run --name coredns --restart=always -d -p 53:53 -p 53:53/udp -v /opt/coredns:/config coredns/coredns -conf /config/Corefile
#View log files of container (use logs -f to follow logs)
docker logs coredns
#Testing (non-persistant container that will be deleted when stopped). Use docker ps to see it's container name
docker run --rm coredns/coredns --help #See command line options (there is no sh or bin in this container)
docker kill --signal="SIGUSR1" coredns #send signal to reload if config is changed (need to use auto plugin to auto reload)
$ORIGIN home.arpa.
@ 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. (
2017042745 ; serial
7200 ; refresh (2 hours)
3600 ; retry (1 hour)
1209600 ; expire (2 weeks)
3600 ; minimum (1 hour)
)
testrecord IN A 127.0.0.1
internal.home.arpa. IN DNAME example.com.
$ dig +additional www.internal.home.arpa
; <<>> DiG 9.10.3-P4-Ubuntu <<>> www.internal.home.arpa
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10972
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.internal.home.arpa. IN A
;; ANSWER SECTION:
internal.home.arpa. 3600 IN DNAME example.com.
www.internal.home.arpa. 3600 IN CNAME www.example.com.
www.example.com. 0 IN A 93.184.216.34
;; Query time: 6 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Sun Aug 19 21:38:24 MDT 2018
;; MSG SIZE rcvd: 150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.