TLS for Hosts in Your Free /48 with ACME DNS-01
Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end. Getti
Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end.
Getting a certificate with the ACME HTTP-01 challenge requires the certificate authority to reach your server on port 80. That is easy for a public web server and awkward for everything else: an admin panel reachable only from a management network, a mail relay, a database with TLS, or any host behind a firewall that blocks inbound HTTP. The DNS-01 challenge proves control of the name through a TXT record instead, so the host never needs to be reachable. This article sets up DNS-01 for hosts numbered from a free IPv6 /48 from IPYE, using certbot with RFC 2136 dynamic updates. The examples use example.net and hosts in 2001:db8:100::/48.
Why HTTP-01 trips over IPv6
When a name has an AAAA record, the certificate authority's validation servers generally try IPv6 first. If the AAAA points to a host where port 80 is closed, or IPv6 routing to it is broken, validation can fail even though IPv4 works fine. This is one of the most common reasons for a failed renewal on a newly dual-stacked server. DNS-01 avoids the question entirely, because validation never contacts the host.
Prepare the DNS server
DNS-01 needs a way for certbot to create and remove a TXT record at _acme-challenge.<name>. With BIND, create a TSIG key and limit it to those names:
tsig-keygen -a hmac-sha256 acme-update. > /etc/bind/acme-update.key
include "/etc/bind/acme-update.key";
zone "example.net" {
type primary;
file "/var/lib/bind/example.net.zone";
update-policy {
grant acme-update. wildcard _acme-challenge.*.example.net. TXT;
grant acme-update. name _acme-challenge.example.net. TXT;
};
};
The wildcard rule allows the key to update only TXT records under _acme-challenge labels. If the key leaks, it cannot change your AAAA or MX records.
An even tighter option is to delegate _acme-challenge names to a separate small zone with CNAME records, so the key cannot touch your main zone at all. That is worth doing once you have more than a handful of hosts.
Install certbot and the plugin
apt install certbot python3-certbot-dns-rfc2136
Create /etc/letsencrypt/rfc2136.ini with mode 600:
dns_rfc2136_server = 2001:db8:100:53::1
dns_rfc2136_port = 53
dns_rfc2136_name = acme-update.
dns_rfc2136_secret = BASE64-SECRET-FROM-KEY-FILE
dns_rfc2136_algorithm = HMAC-SHA256
Request a certificate
certbot certonly --dns-rfc2136 \
--dns-rfc2136-credentials /etc/letsencrypt/rfc2136.ini \
--dns-rfc2136-propagation-seconds 30 \
-d admin.example.net
The propagation delay gives secondary nameservers time to pick up the record before validation. If your secondaries use NOTIFY and IXFR, 30 seconds is usually plenty. Validation queries go to your authoritative servers, so every one of them needs the TXT record when the check happens.
Wildcards are only possible with DNS-01: -d '*.lab.example.net' covers every lab host in one certificate. That suits a lab subnet in the /48, where hosts come and go. For production services, separate certificates per name limit what a single stolen key exposes.
Renewal and deployment
The certbot package installs a systemd timer that renews certificates when they near expiry. Add a deploy hook so services pick up new certificates:
certbot renew --dry-run
# /etc/letsencrypt/renewal-hooks/deploy/reload.sh
#!/bin/sh
systemctl reload nginx
Make the hook executable. --dry-run tests the whole chain against the staging environment without issuing a real certificate.
Hosts that cannot run certbot
Network devices and appliances often cannot run an ACME client. Issue the certificate on a management host with DNS-01, then push it out with a script or configuration management. With DNS-01, the host that requests the certificate does not have to be the host that uses it.
Publish CAA records
A CAA record lists which certificate authorities may issue for your names:
example.net. IN CAA 0 issue "letsencrypt.org"
It is a small extra safeguard against issuance by an authority you do not use. If you use more than one authority, add an issue line for each, and an issuewild line if wildcards should be restricted differently.
Where IPYE fits
The hosts here live in the free /48. For your public-facing names, the routing side needs the LOA from the IPYE dashboard, and the ROA is already handled, created automatically on IPYE's ARIN or APNIC accounts.
Do this next
Request a free /48, set up a narrowly scoped TSIG key for _acme-challenge names, and issue your first DNS-01 certificate for an internal host. Questions: [email protected].
About IPYE
IPYE (https://ipye.com) leases IPv4, IPv6 and ASN space with instant setup. Your first IPv6 /48 is free for the first year, a real allocation you can announce on your own ASN, with a LOA from the portal and the ROA created automatically. ASN and region changes apply automatically. IPv4 /24 to /22 leases include LOA, ROA and per-/24 rDNS; WHOIS is editable on IPv6 /44 and larger. Locations: Los Angeles, New York, Ashburn, Salt Lake City, London, Amsterdam, Frankfurt. Claim your free /48: https://my.ipye.com/products/ipv6-rental. Questions: [email protected].
Disclosure: I run IPYE
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.