2019-08-30 15:58:25 +01:00
. \" Generated by Mmark Markdown Processer - mmark.miek.nl
2026-03-27 05:35:09 +02:00
.TH "COREDNS-IMPORT" 7 "March 2026" "CoreDNS" "CoreDNS Plugins"
2019-04-06 08:42:40 +01:00
2019-06-24 12:37:27 +01:00
.SH "NAME"
2019-04-06 08:42:40 +01:00
.PP
2019-09-27 13:30:22 +01:00
\fI import\fP - includes files or references snippets from a Corefile.
2019-04-06 08:42:40 +01:00
2019-06-24 12:37:27 +01:00
.SH "DESCRIPTION"
2019-04-06 08:42:40 +01:00
.PP
2019-09-27 13:30:22 +01:00
The \fI import\fP plugin can be used to include files into the main configuration. Another use is to
2019-04-06 08:42:40 +01:00
reference predefined snippets. Both can help to avoid some duplication.
.PP
2019-10-10 07:45:28 +01:00
This is a unique plugin in that \fI import\fP can appear outside of a server block. In other words, it
2019-04-06 08:42:40 +01:00
can appear at the top of a Corefile where an address would normally be.
2019-06-24 12:37:27 +01:00
.SH "SYNTAX"
2019-04-06 08:42:40 +01:00
.PP
.RS
2019-01-06 09:15:34 +00:00
2019-04-06 08:42:40 +01:00
.nf
2019-01-06 09:15:34 +00:00
import PATTERN
2019-04-06 08:42:40 +01:00
2019-01-06 09:15:34 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.IP \(bu 4
\fB PATTERN\fP is the file, glob pattern (\fB \fC *\fR ) or snippet to include. Its contents will replace
this line, as if that file's contents appeared here to begin with.
2019-01-06 09:15:34 +00:00
2019-04-06 08:42:40 +01:00
2026-03-27 05:35:09 +02:00
.PP
Corefile may contain at most 10000 import statements. A glob pattern counts as a single import. The limit protects the configuration from recursive imports.
2019-06-24 12:37:27 +01:00
.SH "FILES"
2019-04-06 08:42:40 +01:00
.PP
You can use \fI import\fP to include a file or files. This file's location is relative to the
Corefile's location. It is an error if a specific file cannot be found, but an empty glob pattern is
not an error.
2019-06-24 12:37:27 +01:00
.SH "SNIPPETS"
2019-04-06 08:42:40 +01:00
.PP
You can define snippets to be reused later in your Corefile by defining a block with a single-token
label surrounded by parentheses:
.PP
.RS
.nf
2019-01-06 09:15:34 +00:00
(mysnippet) {
2019-09-27 13:30:22 +01:00
...
2019-01-06 09:15:34 +00:00
}
2019-04-06 08:42:40 +01:00
2019-01-06 09:15:34 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.PP
Then you can invoke the snippet with \fI import\fP :
.PP
.RS
2019-01-06 09:15:34 +00:00
2019-04-06 08:42:40 +01:00
.nf
2019-01-06 09:15:34 +00:00
import mysnippet
2019-04-06 08:42:40 +01:00
2019-01-06 09:15:34 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
2019-06-24 12:37:27 +01:00
.SH "EXAMPLES"
2019-04-06 08:42:40 +01:00
.PP
2019-01-06 09:15:34 +00:00
Import a shared configuration:
2019-04-06 08:42:40 +01:00
.PP
.RS
.nf
\& . {
import config/common.conf
2019-01-06 09:15:34 +00:00
}
2019-04-06 08:42:40 +01:00
2019-01-06 09:15:34 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.PP
Where \fB \fC config/common.conf\fR contains:
2019-01-06 09:15:34 +00:00
2019-04-06 08:42:40 +01:00
.PP
.RS
.nf
2019-01-06 09:15:34 +00:00
prometheus
errors
log
2019-04-06 08:42:40 +01:00
2019-01-06 09:15:34 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
.PP
2019-01-06 09:15:34 +00:00
This imports files found in the zones directory:
2019-04-06 08:42:40 +01:00
.PP
.RS
2019-01-06 09:15:34 +00:00
.nf
2019-04-06 08:42:40 +01:00
import ../zones/*
2019-01-06 09:15:34 +00:00
.fi
2019-04-06 08:42:40 +01:00
.RE
2020-11-05 13:37:38 +00:00
.SH "SEE ALSO"
2019-04-06 08:42:40 +01:00
.PP
See corefile(5).