From 33b4d2b7487437d7c7d74701f7946abd6786dcf0 Mon Sep 17 00:00:00 2001 From: Craig Peterson Date: Mon, 20 Mar 2017 21:47:18 -0600 Subject: [PATCH] Adding example page to docs --- docs/examples.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.md | 2 ++ 2 files changed, 77 insertions(+) create mode 100644 docs/examples.md diff --git a/docs/examples.md b/docs/examples.md new file mode 100644 index 000000000..81dc0c55c --- /dev/null +++ b/docs/examples.md @@ -0,0 +1,75 @@ +--- +layout: default +--- + +# Examples + +* TOC +{:toc} + +## Variables for common IP Addresses + +{% highlight javascript %} + +var addrA = IP("1.2.3.4") + +D("example.com", REG, DnsProvider("R53"), + A("@", addrA), //1.2.3.4 + A("www", addrA + 1), //1.2.3.5 +) +{% endhighlight %} + +## Variables to swap active Data Center + +{% highlight javascript %} + +var dcA = IP("5.5.5.5"); +var dcB = IP("6.6.6.6"); + +// switch to dcB to failover +var activeDC = dcA; + +D("example.com", REG, DnsProvider("R53"), + A("@", activeDC + 5), // fixed address based on activeDC +) +{% endhighlight %} + +## Macro to group repeated records + +{% highlight javascript %} + +var GOOGLE_APPS_DOMAIN_MX = [ + MX('@', 1, 'aspmx.l.google.com.'), + MX('@', 5, 'alt1.aspmx.l.google.com.'), + MX('@', 5, 'alt2.aspmx.l.google.com.'), + MX('@', 10, 'alt3.aspmx.l.google.com.'), + MX('@', 10, 'alt4.aspmx.l.google.com.'), +] + +D("example.com", REG, DnsProvider("R53"), + GOOGLE_APPS_DOMAIN_MX, + A("@", "1.2.3.4") +) +{% endhighlight %} + +## Dual DNS Providers + +{% highlight javascript %} + +D("example.com", REG, DnsProvider("R53"), DnsProvider("GCLOUD"), + A("@", "1.2.3.4") +) + +// above zone uses 8 NS records total (4 from each provider dynamically gathered) +// below zone will only take 2 from each for a total of 4. May be better for performance reasons. + +D("example2.com", REG, DnsProvider("R53",2), DnsProvider("GCLOUD",2), + A("@", "1.2.3.4") +) + +// or set a Provider as a non-authoritative backup (don't register its nameservers) +D("example3.com", REG, DnsProvider("R53"), DnsProvider("GCLOUD",0), + A("@", "1.2.3.4") +) + +{% endhighlight %} \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 960255db6..e7327b129 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,6 +11,8 @@ Dnscontrol is a platform for seamlessly managing your dns configuration across a ## [Language Reference]({{site.github.url}}/js) +## [Examples]({{site.github.url}}/examples) + ## [github](https://github.com/StackExchange/dnscontrol)