|
| 1 | ++++ |
| 2 | +title = "flatten" |
| 3 | +description = "*<plugin name>* provides minimal CNAME flattening mirroring the Cloudflare RFC 1034 compliant implementation." |
| 4 | +weight = 10 |
| 5 | +tags = [ "plugin" , "<plugin name>" ] |
| 6 | +categories = [ "plugin", "external" ] |
| 7 | +date = "2017-07-22T12:37:19+01:00" |
| 8 | +repo = "https://github.com/litobro/flatten" |
| 9 | +home = "https://github.com/litobro/flatten/blob/main/README.md" |
| 10 | ++++ |
| 11 | + |
| 12 | +## Description |
| 13 | + |
| 14 | +The *<plugin name>* plugin is an attempt to provide a minimal CNAME flattening solution that is RFC compliant in accordance with the Cloudflare implementation. |
| 15 | + |
| 16 | +## Syntax |
| 17 | + |
| 18 | +~~~ txt |
| 19 | +flatten [FROM] [TO] [DNSIP:PORT] |
| 20 | +~~~ |
| 21 | + |
| 22 | +- `FROM`: Original requested NAME |
| 23 | +- `TO`: Name to overwrite the A and AAAA records from |
| 24 | +- `DNSIP:PORT`: The DNS server and port to resolve the `TO` records from |
| 25 | + |
| 26 | +## Example Corefile |
| 27 | +``` |
| 28 | +example.org:53 { |
| 29 | + log |
| 30 | + flatten example.org google.ca 1.1.1.1:53 |
| 31 | +
|
| 32 | + forward . 1.1.1.1 |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +### Example output |
| 37 | +Run the server |
| 38 | +``` |
| 39 | +$ ./coredns -conf Corefile |
| 40 | +
|
| 41 | +example.org.:53 |
| 42 | +CoreDNS-1.11.2 |
| 43 | +linux/amd64, go1.21.8, 8de4531d-dirty |
| 44 | +[INFO] plugin/flatten: 127.0.0.1:37237 - [example.org.] flattened to [google.ca.] via 1.1.1.1:53 |
| 45 | +[INFO] plugin/flatten: 127.0.0.1:36670 - [example.org.] flattened to [google.ca.] via 1.1.1.1:53 |
| 46 | +``` |
| 47 | + |
| 48 | +Make a DNS request to the server |
| 49 | +``` |
| 50 | +$ nslookup example.org 127.0.0.1 |
| 51 | +
|
| 52 | +Server: 127.0.0.1 |
| 53 | +Address: 127.0.0.1#53 |
| 54 | +
|
| 55 | +Name: example.org |
| 56 | +Address: 142.250.217.67 |
| 57 | +Name: example.org |
| 58 | +Address: 2607:f8b0:400a:80b::2003 |
| 59 | +Name: example.org |
| 60 | +Address: 142.250.217.67 |
| 61 | +Name: example.org |
| 62 | +Address: 2607:f8b0:400a:804::2003 |
| 63 | +
|
| 64 | +$ dig TXT example.org @127.0.0.1 |
| 65 | +
|
| 66 | +; <<>> DiG 9.18.18-0ubuntu0.22.04.1-Ubuntu <<>> TXT example.org @127.00.0.1 |
| 67 | +;; global options: +cmd |
| 68 | +;; Got answer: |
| 69 | +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63388 |
| 70 | +;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 |
| 71 | +
|
| 72 | +;; OPT PSEUDOSECTION: |
| 73 | +; EDNS: version: 0, flags:; udp: 1232 |
| 74 | +;; QUESTION SECTION: |
| 75 | +;example.org. IN TXT |
| 76 | +
|
| 77 | +;; ANSWER SECTION: |
| 78 | +example.org. 86400 IN TXT "v=spf1 -all" |
| 79 | +example.org. 86400 IN TXT "6r4wtj10lt2hw0zhyhk7cgzzffhjp7fl" |
| 80 | +
|
| 81 | +;; Query time: 99 msec |
| 82 | +;; SERVER: 127.0.0.1#53(127.00.0.1) (UDP) |
| 83 | +;; WHEN: Wed Apr 17 09:42:46 MDT 2024 |
| 84 | +;; MSG SIZE rcvd: 131 |
0 commit comments