-
Notifications
You must be signed in to change notification settings - Fork 4.6k
CE-655 - Moving DNS forwading tutorial to docs #21348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e2f53f7
First commit
danielehc f2a7a3e
Add page to navigation
danielehc 689c25a
test new doc page
danielehc b116396
Merge branch 'main' into CE-655
danielehc d38a6fd
Update website/content/docs/services/discovery/dns-forwarding.mdx
danielehc 4d0310e
Update website/content/docs/services/discovery/dns-forwarding.mdx
danielehc e099611
fix push build atttempt
boruszak 344307d
Draft
danielehc 5f5b70d
Draft
danielehc 484ea76
empty line
boruszak a1b4fc2
Draft
danielehc 0b4e01e
empty lines
boruszak 0819eb8
Draft
danielehc 726bc94
First draft
danielehc 62bbe44
Create documentation for Argo Rollouts Plugin. (#20680)
23485a3
Split content and add images
danielehc 015e545
Merge branch 'main' into CE-655
danielehc a1fd33f
Fix navigation
danielehc 4b6037f
Add links and context
danielehc 2d3ca78
Restructure changes
boruszak f18694b
Merge branch 'main' into CE-655
danielehc eca25e9
Fix enable documentation
danielehc 17847a6
Merge branch 'main' into CE-655
danielehc 4ce5c50
Fix enable documentation
danielehc 05db00e
Fix index documentation
danielehc d4047a8
Add troubleshooting and fix codeblocks
danielehc 7b86c7e
Add troubleshooting and fix codeblocks
danielehc 60279b2
Typos and last checks
danielehc 7851b18
Apply suggestions from code review
danielehc f05b497
Apply suggestions from code review
danielehc 25c8169
Merge branch 'main' into CE-655
danielehc c46a2ba
Update website/content/docs/services/discovery/dns-forwarding/enable.mdx
danielehc 0b3cd01
Merge branch 'main' into CE-655
danielehc 609a59b
Apply suggestions from code review
danielehc d758f6b
Add dark mode images
danielehc adf209f
Merge branch 'main' into CE-655
danielehc a74664d
Add dark mode images
danielehc e4abe13
Apply suggestions from code review
danielehc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
420 changes: 420 additions & 0 deletions
420
website/content/docs/services/discovery/dns-forwarding/enable.mdx
Large diffs are not rendered by default.
Oops, something went wrong.
186 changes: 186 additions & 0 deletions
186
website/content/docs/services/discovery/dns-forwarding/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| --- | ||
| layout: docs | ||
| page_title: DNS forwarding | ||
| description: -> | ||
| Learn how to configure your local DNS servers to perform DNS forwarding to Consul servers. | ||
| --- | ||
|
|
||
| # DNS forwarding | ||
|
|
||
| This topic describes the process to configure different DNS servers to enable DNS forwarding to Consul servers. | ||
|
|
||
| You can apply these operations on every node where a Consul agent is running. | ||
|
|
||
| ## Introduction | ||
|
|
||
| You deployed a Consul datacenter and want to use Consul DNS interface for name resolution. | ||
|
|
||
| When configured with default values, Consul exposes the DNS interface on port `8600`. By default, DNS is served from port `53`. On most operating systems, this requires elevated privileges. It is also common, for most operating systems, to have a local DNS server already running on port `53`. | ||
|
|
||
| Instead of running Consul with an administrative or root account, you can forward appropriate queries to Consul, running on an unprivileged port, from another DNS server or using port redirect. | ||
|
|
||
| There are two configurations for a node's DNS forwarding behavior: | ||
| - **Conditional DNS forwarding**: the local DNS servers are configured to forward to Consul only queries relative to the `.consul` zone. All other queries are still served via the default DNS server in the node. | ||
| - **Full DNS forwarding**: Consul serves all DNS queries and forwards to a remote DNS server the ones outside `.consul` domain. | ||
|
|
||
| ### Conditional DNS forwarding | ||
|
|
||
| We recommend the conditional DNS forwarding approach. This configuration lowers the Consul agent's resource consumption by limiting the number of DNS requests it handles. | ||
|
|
||
|  | ||
|  | ||
|
|
||
| In this configuration, Consul only serves queries relative to the `.consul` domain. There is no unnecessary load on Consul servers to serve queries from different domains. | ||
danielehc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| This behavior is not enabled by default. | ||
|
|
||
| ### Full DNS forwarding | ||
|
|
||
| This approach can be useful in scenarios where the Consul agent's node is allocated limited resources and you want to avoid the overhead of running a local DNS server. In this configuration, Consul serves all DNS queries for all domains and forwards the ones outside the `.consul` domain to one or more configured forwarder servers. | ||
|
|
||
|  | ||
|  | ||
|
|
||
| This behavior is not enabled by default. Consul standard configuration only resolves DNS records inside the `.consul` zone. To enable DNS forwarding, you need to set the [recursors](/consul/docs/agent/config/config-files#recursors) option in your Consul configuration. | ||
|
|
||
| In this scenario, if a Consul DNS reply includes a `CNAME` record pointing outside the `.consul` top level domain, then the DNS reply only includes `CNAME` records by default. | ||
|
|
||
| When `recursors` is set and the upstream resolver is functioning correctly, Consul tries to resolve CNAMEs and include any records (for example, A, AAAA, PTR) for them in its DNS reply. In these scenarios, Consul is used for full DNS forwarding and is able to serve queries for all domains. | ||
|
|
||
| ## Workflow | ||
|
|
||
| To use DNS forwarding in Consul deployments, complete the following steps: | ||
|
|
||
| 1. Configure the local DNS service to enable DNS forwarding to Consul. Follow the instructions for one of the following services: | ||
|
|
||
| - [systemd-resolved](/consul/docs/services/discovery/dns-forwarding/enable#systemd-resolved) | ||
| - [BIND](/consul/docs/services/discovery/dns-forwarding/enable#bind) | ||
| - [Dnsmasq](/consul/docs/services/discovery/dns-forwarding/enable#dnsmasq) | ||
| - [Unbound](/consul/docs/services/discovery/dns-forwarding/enable#unbound) | ||
| - [iptables](/consul/docs/services/discovery/dns-forwarding/enable#iptables) | ||
| - [macOS system resolver](/consul/docs/services/discovery/dns-forwarding/enable#macOS) | ||
|
|
||
| 1. Query the Consul DNS to confirm that DNS forwarding functions correctly. | ||
|
|
||
| ```shell-session | ||
| $ dig consul.service.consul A | ||
|
|
||
| ; <<>> DiG 9.16.48-Debian <<>> consul.service.consul A | ||
| ;; global options: +cmd | ||
| ;; Got answer: | ||
| ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51736 | ||
| ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1 | ||
|
|
||
| ;; OPT PSEUDOSECTION: | ||
| ; EDNS: version: 0, flags:; udp: 65494 | ||
| ;; QUESTION SECTION: | ||
| ;consul.service.consul. IN A | ||
|
|
||
| ;; ANSWER SECTION: | ||
| consul.service.consul. 0 IN A 10.0.4.140 | ||
| consul.service.consul. 0 IN A 10.0.4.121 | ||
| consul.service.consul. 0 IN A 10.0.4.9 | ||
|
|
||
| ;; Query time: 4 msec | ||
| ;; SERVER: 127.0.0.53#53(127.0.0.53) | ||
| ;; WHEN: Wed Jun 26 20:47:05 UTC 2024 | ||
| ;; MSG SIZE rcvd: 98 | ||
|
|
||
| ``` | ||
|
|
||
| 1. Optionally, verify reverse DNS. | ||
|
|
||
| ```shell-session | ||
| $ dig 140.4.0.10.in-addr.arpa. PTR | ||
|
|
||
| ; <<>> DiG 9.16.48-Debian <<>> 140.4.0.10.in-addr.arpa. PTR | ||
| ;; global options: +cmd | ||
| ;; Got answer: | ||
| ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35085 | ||
| ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 | ||
|
|
||
| ;; OPT PSEUDOSECTION: | ||
| ; EDNS: version: 0, flags:; udp: 65494 | ||
| ;; QUESTION SECTION: | ||
| ;140.4.0.10.in-addr.arpa. IN PTR | ||
|
|
||
| ;; ANSWER SECTION: | ||
| 140.4.0.10.in-addr.arpa. 0 IN PTR consul-server-0.node.dc1.consul. | ||
|
|
||
| ;; Query time: 0 msec | ||
| ;; SERVER: 127.0.0.53#53(127.0.0.53) | ||
| ;; WHEN: Wed Jun 26 20:47:57 UTC 2024 | ||
| ;; MSG SIZE rcvd: 97 | ||
|
|
||
| ``` | ||
|
|
||
| You can use the `short` option for `dig` to only get the node name instead of the full output. | ||
|
|
||
| ```shell-session | ||
| $ dig +short -x 10.0.4.140 | ||
| consul-server-0.node.dc1.consul. | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| If your DNS server does not respond but you do get an answer from Consul, turn on your DNS server's query log to check for errors. | ||
|
|
||
| ### systemd-resolved | ||
|
|
||
| Enable query logging for `systemd-resolved`: | ||
|
|
||
| ```shell-session | ||
| # resolvectl log-level debug | ||
| ``` | ||
|
|
||
| Check query log: | ||
|
|
||
| ```shell-session | ||
| # journalctl -r -u systemd-resolved | ||
| ``` | ||
|
|
||
| Disable query logging: | ||
|
|
||
| ```shell-session | ||
| # resolvectl log-level info | ||
| ``` | ||
|
|
||
| DNS forwarding may fail if you use the default `systemd-resolved` configuration and attempt to bind to `0.0.0.0`. The default configuration uses a DNS stub that listens for UDP and TCP requests at `127.0.0.53`. As a result, attempting to bind to `127.0.0.53` conflicts with the running stub. You can disable the stub as described in the [Using any local resolver with systemd](/consul/docs/services/discovery/dns-forwarding/enable#using-any-local-resolver-with-systemd) section to troubleshoot this problem. | ||
|
|
||
| ### Dnsmasq | ||
|
|
||
| To enable query log refer to [Dnsmasq documentation](https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html). | ||
|
|
||
| In particular, look for the `log-queries` and `log-facility` configuration option. | ||
|
|
||
| When query log is enabled, it is possible to force Dnsmasq to emit a full cache dump using the `SIGUSR1` signal. | ||
|
|
||
| ### BIND | ||
|
|
||
| Enable query log: | ||
|
|
||
| ```shell-session | ||
| $ rndc querylog | ||
| ``` | ||
|
|
||
| Check logs: | ||
|
|
||
| ```shell-session | ||
| $ tail -f /var/log/messages | ||
| ``` | ||
|
|
||
| The log may show errors like this: | ||
|
|
||
| <CodeBlockConfig hideClipboard> | ||
|
|
||
| ```plaintext | ||
| error (no valid RRSIG) resolving | ||
| error (no valid DS) resolving | ||
| ``` | ||
|
|
||
| </CodeBlockConfig> | ||
|
|
||
| This error indicates that `DNSSEC` is not disabled properly. | ||
|
|
||
| If you receive errors about network connections, verify that there are no firewall | ||
| or routing problems between the servers running BIND and Consul. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.