Skip to content
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

Add custom upstream DNS resolver #84

Merged
merged 1 commit into from
Jan 1, 2024

Conversation

Injabie3
Copy link
Contributor

In Unifi Network, the upstream DNS resolver can be configured. This can be done in Settings > Internet under IPv4 Configuration.

In some cases, such as an environment with Microsoft Active Directory (AD) for a domain example.com, there may be a need to change the upstream DNS resolver to point to a DNS server within the internal network (i.e. the AD's DNS server) to handle all DNS queries for example.com.

When this is done, any certificate requests for the example.com domain and subdomains will fail to complete the initial local verification step because the upstream DNS server (i.e. AD server) is the authoritative name server for example.com and will not see the DNS changes applied to the external DNS provider, so it returns NXDOMAIN to LEGO.

To address the above issue, this commit adds a DNS_RESOLVER environment variable that is passed into the LEGO client in the --dns.resolvers flag to specific a different upstream DNS resolver to verify the new DNS entry locally. The default was chosen to be the loopback, as this was the one seen when LEGO was invoked by the script before these changes:

[INFO] [some.example.com] acme: use dns-01 solver
[INFO] [some.example.com] acme: Preparing to solve DNS-01
[INFO] cloudflare: new record for some.example.com, ID ########
[INFO] [some.example.com] acme: Trying to solve DNS-01
[INFO] [some.example.com] acme: Checking DNS record propagation using [127.0.0.1:53]

These changes were verified on a UDM SE running Unifi OS v3.2.7 and Network 8.0.24.

In Unifi Network, the upstream DNS resolver can be configured. This can
be done in Settings > Internet under IPv4 Configuration.

In some cases, such as an environment with Microsoft Active Directory
(AD) for a domain example.com, there may be a need to change the
upstream DNS resolver to point to a DNS server within the internal
network (i.e. the AD's DNS server) to handle all DNS queries for
example.com.

When this is done, any certificate requests for the example.com domain
and subdomains will fail to complete the initial local verification step
because the upstream DNS server (i.e. AD server) is the authoritative
name server for example.com and will not see the DNS changes applied to
the external DNS provider, so it returns NXDOMAIN to LEGO.

To address the above issue, this commit adds a DNS_RESOLVER environment
variable that is passed into the LEGO client in the `--dns.resolvers`
flag to specific a different upstream DNS resolver to verify the new
DNS entry locally. The default was chosen to be the loopback, as this
was the one seen when LEGO was invoked by the script before these
changes:

```
[INFO] [some.example.com] acme: use dns-01 solver
[INFO] [some.example.com] acme: Preparing to solve DNS-01
[INFO] cloudflare: new record for some.example.com, ID ########
[INFO] [some.example.com] acme: Trying to solve DNS-01
[INFO] [some.example.com] acme: Checking DNS record propagation using [127.0.0.1:53]
```

These changes were verified on a UDM SE running Unifi OS v3.2.7 and
Network 8.0.24.
Copy link
Owner

@kchristensen kchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for your contribution!

@kchristensen kchristensen merged commit 98a5079 into kchristensen:main Jan 1, 2024
@Injabie3 Injabie3 deleted the dns-upstream branch January 2, 2024 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants