惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

PCI Perspectives
PCI Perspectives
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
V
Visual Studio Blog
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Security Affairs
S
SegmentFault 最新的问题
C
Cisco Blogs
博客园 - 聂微东
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
量子位
T
The Exploit Database - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Latest
Security Latest
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog

CoreDNS: DNS and Service Discovery

CoreDNS-1.14.2 Release CoreDNS-1.14.1 Release CoreDNS-1.14.0 Release CoreDNS-1.13.2 Release CoreDNS-1.13.1 Release CoreDNS-1.13.0 Release CoreDNS-1.12.4 Release CoreDNS-1.12.3 Release CoreDNS-1.12.2 Release CoreDNS-1.12.1 Release CoreDNS-1.12.0 Release CoreDNS-1.11.4 Release CoreDNS-1.11.3 Release k8s_cache CoreDNS-1.11.2 Release CoreDNS-1.11.1 Release CoreDNS-1.11.0 Release CoreDNS-1.10.1 Release CoreDNS-1.10.0 Release CoreDNS-1.9.4 Release CoreDNS-1.9.3 Release CoreDNS-1.9.2 Release CoreDNS-1.9.1 Release CoreDNS and Apache APISIX open new doors for Service Discovery? Trail Of Bits Security Review CoreDNS-1.9.0 Release CoreDNS-1.8.7 Release CoreDNS-1.8.6 Release CoreDNS-1.8.5 Release CoreDNS-1.8.4 Release CoreDNS-1.8.3 Release CoreDNS-1.8.2 Release CoreDNS-1.8.1 Release CoreDNS-1.8.0 Release k8s_dns_chaos CoreDNS-1.7.1 Release k8s_gateway CoreDNS-1.7.0 Release CoreDNS-1.6.8 Release CoreDNS-1.6.9 Release CoreDNS-1.6.7 Release CoreDNS-1.6.6 Release CoreDNS-1.6.5 Release CoreDNS-1.6.4 Release CoreDNS-1.6.3 Release CoreDNS-1.6.2 Release CoreDNS-1.6.1 Release CoreDNS-1.6.0 Release CoreDNS-1.5.2 Release CoreDNS-1.5.1 Release CoreDNS-1.5.0 Release CoreDNS-1.4.0 Release CoreDNS-1.3.1 Release CoreDNS-1.3.0 Release Cluster DNS: CoreDNS vs Kube-DNS Scaling CoreDNS in Kubernetes Clusters CoreDNS-1.2.6 Release CoreDNS-1.2.5 Release CoreDNS-1.2.4 Release CoreDNS-1.2.3 Release CoreDNS-1.2.2 Release CoreDNS-1.2.1 Release CoreDNS-1.2.0 Release CoreDNS-1.1.4 Release CoreDNS-1.1.3 Release Migration from kube-dns to CoreDNS CoreDNS-1.1.2 Release CoreDNS-1.1.1 Release Cure53 Security Assessment CoreDNS-1.1.0 Release kubernetai CoreDNS-1.0.6 Release CoreDNS Manual Deploying Kubernetes with CoreDNS using kubeadm CoreDNS-1.0.5 Release CoreDNS-1.0.4 Release CoreDNS-1.0.3 Release CoreDNS-1.0.2 Release CoreDNS-1.0.1 Release CoreDNS-1.0.0 Release CoreDNS-0.9.10 Release Setting up CoreDNS (on AWS) CoreDNS-0.9.9 Release Semantic Versioning CoreDNS-011 Release A first look at CoreDNS CoreDNS Performance Testing Logging with dnstap Intro to CoreDNS webinar by John Belamaric CoreDNS-010 Release Compile Time Enabling or Disabling Plugins When Should Plugins be External? Add External Plugins Corefile Explained CoreDNS-009 Release CoreDNS-008 Release How Queries Are Processed in CoreDNS Custom DNS Entries For Kubernetes CoreDNS-007 Release CoreDNS for Minikube
Quick Start
miek · 2017-07-24 · via CoreDNS: DNS and Service Discovery

First get CoreDNS, either

  • Download the latest release from GitHub, unpack it. You should now have a “coredns” executable.

  • Compile from git by getting the source code from GitHub. Change directory to coredns and:

    • go get - to get a few dependencies, the other ones are vendored
    • go build

    You should now have a “coredns” executable.

  • Get the Docker image from docker hub.

If you want to use CoreDNS in Kubernetes, please check this post about SD with the kuberneters plugin.

The remainder of this quick start will focus and two different use cases

  1. Using CoreDNS to serve zone files. Optionally signing the zones as well.
  2. Using CoreDNS as a forwarding proxy.

CoreDNS is configured via a configuration file that it typically called Corefile.

Serving from Files

When serving from zone files you use the file plugin. Let’s start with the zone example.org. and zonefile we want to serve from:

Create a file example.org with the following content:

$ORIGIN example.org.
@	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)
				)

	3600 IN NS a.iana-servers.net.
	3600 IN NS b.iana-servers.net.

www     IN A     127.0.0.1
        IN AAAA  ::1

Create a Corefile, Corefile, with:

example.org {
    file example.org
    prometheus     # enable metrics
    errors         # show errors
    log            # enable query logs
}

Start CoreDNS on a non-standard port to check if everything is correct: coredns -conf Corefile -dns.port 1053 and send it a query with dig:

% dig -p 1053 @localhost AAAA www.example.org +noall +answer

www.example.org.	3600	IN	AAAA	::1

As we’ve enabled query loggin with the log plugin the query should be show up on standard output as well:

::1 - [24/Jul/2017:10:10:44 +0000] "AAAA IN www.example.org. udp 45 false 4096" NOERROR 121 133.449µs

From here you can enable CoreDNS to run on port 53 and have it start from systemd (when on Linux), see the deployment repo for example scripts. Read more about the file, metrics and errors plugin.

CoreDNS as proxy

Another plugin is the proxy plugin. We can for instance send DNS request to Google over HTTPS. Create a Corefile with:

. {
    proxy . 8.8.8.8:53 {
        protocol https_google
    }
    prometheus
    errors
    log
}

Start CoreDNS, just like above and send it a few queries. CoreDNS should logs those, in this case:

::1 - [24/Jul/2017:10:44:15 +0000] "AAAA IN www.example.org. udp 45 false 4096" NOERROR 76 83.396955ms
::1 - [24/Jul/2017:10:44:17 +0000] "AAAA IN www.example.org. udp 45 false 4096" NOERROR 76 14.030914ms
::1 - [24/Jul/2017:10:44:19 +0000] "AAAA IN www.example.org. udp 45 false 4096" NOERROR 76 13.286384ms

If you look at the time each query took (in “ms”) it’s quite slow, ~83ms, 13ms. So let’s add some caching and enable the caching plugin. Just add the word “cache” to the Corefile and graceful reload CoreDNS: kill -SIGUSR1 <pid_of_coredns>. And query again:

::1 - [24/Jul/2017:11:33:54 +0000] "AAAA IN www.example.org. udp 45 false 4096" NOERROR 76 43.469743ms
::1 - [24/Jul/2017:11:33:55 +0000] "AAAA IN www.example.org. udp 45 false 4096" NOERROR 73 133.073µs

First one is still “slow”, but the subsequent query only takes 133 µs.

Possible Errors

The health’s documentation states “This plugin only needs to be enabled once”, which might lead you to think that this would be a valid Corefile:

But this doesn’t work and leads to the somewhat cryptic error:

"Corefile:3 - Error during parsing: Unknown directive '.'".

What happens here? health is seen as zone and now the parser expect to see directives (cache, etcd, etc.), but instead the next token is ., which isn’t a directive. The Corefile should be constructed as follows:

. {
    whoami
    health
}

That line in the health’s documentation means that once health is specified, it is global for the entire CoreDNS process, even though you’ve only specified it for one server.

Also See

There are numerous other plugins that can be used with CoreDNS. And you can write your own plugin.

How queries are processed is a deep dive into how CoreDNS handles DNS queries.