| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | ## Name
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | *corefile* - configuration file for CoreDNS. | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | ## Description
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | A *corefile* specifies the internal servers CoreDNS should run and what plugins each of these | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | should chain. The syntax is as follows: | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ~~~ txt | 
					
						
							|  |  |  |  | [SCHEME://]ZONE [[SCHEME://]ZONE]...[:PORT] { | 
					
						
							|  |  |  |  |     [PLUGIN]... | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | The **ZONE** defines for which name this server should be called, multiple zones are allowed and | 
					
						
							|  |  |  |  | should be *white space* separated. You can use a "reverse" syntax to specify a reverse zone (i.e. | 
					
						
							| 
									
										
										
										
											2018-06-29 12:36:12 +01:00
										 |  |  |  | ip6.arpa and in-addr.arpa), by using an IP address in the CIDR notation. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | The optional **SCHEME** defaults to `dns://`, but can also be `tls://` (DNS over TLS), `grpc://` | 
					
						
							|  |  |  |  | (DNS over gRPC) or `https://` (DNS over HTTP/2). | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | The optional **PORT** controls on which port the server will bind, this default to 53. If you use | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | a port number here, you *can't* override it with `-dns.port` (coredns(1)), also see coredns-bind(7). | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-03 20:47:28 +01:00
										 |  |  |  | Specifying a **ZONE** *and* **PORT** combination multiple times for *different* servers will lead to | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | an error on startup. | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-29 12:36:12 +01:00
										 |  |  |  | When a query comes in, it is matched again all zones for all servers, the server with the longest | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | match on the query name will receive the query. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | **PLUGIN** defines the plugin(s) we want to load into this server. This is optional as well, but as | 
					
						
							|  |  |  |  | server with no plugins will just return SERVFAIL for all queries. Each plugin can have a number of | 
					
						
							| 
									
										
										
										
											2018-06-29 12:36:12 +01:00
										 |  |  |  | properties than can have arguments, see the documentation for each plugin. | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-29 12:36:12 +01:00
										 |  |  |  | Comments are allowed and begin with an unquoted hash `#` and continue to the end of the line. | 
					
						
							|  |  |  |  | Comments may be started anywhere on a line. | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 17:55:55 +02:00
										 |  |  |  | Environment variables are supported and either the Unix or Windows form may be used: `{$ENV_VAR_1}` | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | or `{%ENV_VAR_2%}`. | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | You can use the `import` "plugin" (See coredns-import(7)) to include parts of other files. | 
					
						
							| 
									
										
										
										
											2019-01-06 03:41:47 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | If CoreDNS can’t find a Corefile to load it loads the following builtin one: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-03 20:47:28 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | . { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							| 
									
										
										
										
											2019-12-14 20:57:33 +08:00
										 |  |  |  |     log | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-03 20:47:28 +01:00
										 |  |  |  | ## Import
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | You can use the `import` "plugin" to include parts of other files, see | 
					
						
							|  |  |  |  | <https://coredns.io/plugins/import>, and coredns-import(7). | 
					
						
							| 
									
										
										
										
											2019-01-03 20:47:28 +01:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | ## Snippets
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | If you want to reuse a snippet you can define one with and then use it with *import*. | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2019-01-03 20:47:28 +01:00
										 |  |  |  | (mysnippet) { | 
					
						
							|  |  |  |  |     log | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | . { | 
					
						
							|  |  |  |  |     import mysnippet | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | ## Examples
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | The **ZONE** is root zone `.`, the **PLUGIN** is *chaos*. The *chaos* plugin takes an (optional) argument: | 
					
						
							|  |  |  |  | `CoreDNS-001`. This text is returned on a CH class query: `dig CH TXT version.bind @localhost`. | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | . { | 
					
						
							|  |  |  |  |    chaos CoreDNS-001 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | When defining a new zone, you either create a new server, or add it to an existing one. Here we | 
					
						
							|  |  |  |  | define one server that handles two zones; that potentially chain different plugins: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | example.org { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | org { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Is identical to: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | example.org org { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Reverse zones can be specified as domain names: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 0.0.10.in-addr.arpa { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | or by just using the CIDR notation: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 10.0.0.0/24 { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | This also works on a non octet boundary: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-06 08:42:40 +01:00
										 |  |  |  | ~~~ corefile | 
					
						
							| 
									
										
										
										
											2018-01-06 15:53:33 +00:00
										 |  |  |  | 10.0.0.0/27 { | 
					
						
							|  |  |  |  |     whoami | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ~~~ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ## Authors
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | CoreDNS Authors. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ## Copyright
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Apache License 2.0 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ## See Also
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | The manual page for CoreDNS: coredns(1) and more documentation on <https://coredns.io>. | 
					
						
							| 
									
										
										
										
											2019-04-21 22:38:40 +01:00
										 |  |  |  | Also see the [*import*](https://coredns.io/plugins/import)'s documentation and all the manual pages | 
					
						
							|  |  |  |  | for the plugins. |