1
0
Fork 0
alias/README.md

73 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2017-08-20 09:55:02 +08:00
2021-01-24 09:40:55 +08:00
# alias
2017-08-20 09:55:02 +08:00
2017-12-24 05:30:54 +08:00
The *alias* plugin eliminates CNAME records from zone apex by making the subsequent resolved records look like they belong to the zone apex. This behaves similarily to [CloudFlare's Zone Flattening](https://support.cloudflare.com/hc/en-us/articles/200169056-CNAME-Flattening-RFC-compliant-support-for-CNAME-at-the-root).
2017-08-20 09:55:02 +08:00
2020-04-25 16:32:28 +08:00
This plugin works only with plugins that produce A or AAAA records alongside the CNAME record. Examples include `auto` and `file`. However, you might need to adjust the order of this plugin to use it with other plugins.
2017-12-24 05:30:54 +08:00
> Preferrably, this should not be used in favour of the RFC drafts for the new [ANAME](https://tools.ietf.org/html/draft-ietf-dnsop-aname-00) records, but the DNS library used by CoreDNS does not support ANAME records yet.
2017-08-20 09:55:02 +08:00
2021-01-24 09:40:55 +08:00
Release builds can be found [here](https://github.com/serverwentdown/alias/releases)
2020-04-25 18:14:35 +08:00
2017-12-24 05:30:54 +08:00
## Syntax
2017-08-20 09:55:02 +08:00
```
2017-12-24 05:30:54 +08:00
alias
2017-08-20 09:55:02 +08:00
```
2017-12-24 05:30:54 +08:00
## Examples
2017-08-20 09:55:02 +08:00
```
example.com {
2020-04-25 16:32:28 +08:00
file db.example.com
alias
}
# This is used to resolve CNAME records by the `file` plugin. Modify accordingly
. {
forward . 1.1.1.1 1.0.0.1
2017-08-20 09:55:02 +08:00
}
```
2020-04-25 16:32:28 +08:00
This will transform responses like this:
2017-08-20 09:55:02 +08:00
```
;; ANSWER SECTION:
2020-04-25 16:32:28 +08:00
example.com. 3600 IN CNAME two.example.org.
two.example.org. 3600 IN CNAME one.example.net.
one.example.net. 3600 IN A 127.0.0.1
2017-08-20 09:55:02 +08:00
```
into
```
;; ANSWER SECTION:
2020-04-25 16:32:28 +08:00
example.com. 3600 IN A 127.0.0.1
2017-08-20 09:55:02 +08:00
```
2017-12-24 05:30:54 +08:00
2020-04-25 19:13:52 +08:00
See [`example/`](example/) for a more extensive example.
2020-04-25 16:32:28 +08:00
2017-12-24 05:30:54 +08:00
## Installation
2020-04-25 16:32:28 +08:00
As per [CoreDNS docs](https://coredns.io/2017/07/25/compile-time-enabling-or-disabling-plugins/), there are two ways.
### Build with compile-time configuration file
2017-12-24 05:30:54 +08:00
```
2020-04-25 16:32:28 +08:00
$ git clone https://github.com/coredns/coredns
$ cd coredns
2017-12-24 05:30:54 +08:00
$ vim plugin.cfg
# Add the line alias:github.com/serverwentdown/alias before the file middleware
$ go generate
$ go build
$ ./coredns -plugins | grep alias
```
2020-04-25 16:32:28 +08:00
### Build with external golang source code
```
$ git clone https://github.com/serverwentdown/alias
$ cd alias/coredns
$ go build
$ ./coredns -plugins | grep alias
```