Added zone-serial increment support for dns_nsd challenge #5241
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.
As the title says -- inspired by #4137 and my own necessity I wrote a dirty patch to
./dnsapi/dns_nsd.sh
to update the serial number.Essentially it uses
sed
to parse out the old number. This should work in most circumstances, my own zone files look like this, and this works:In a nutshell, the parsing algorithm goes like this:
IN SOA
line)
;
onwards)(
and)
take the 1st entryThis is fairly robust as long as the sysadmin doesn't go out of their way to screw things up. (What they could do to make this fail: insert "IN SOA" in a comment line, split IN and SOA on two different lines, ...generally use less stuff which will, of course, confuse a simple
sed
based parser).Then another
sed
-call is used to replace the existing serial number by a version which is incremented by 1 (bash's$[...]
math support). Thenmktemp
is used to create a temporary zonefile with the updated number, which is thenmv
'ed over the originalNsd_ZoneFile
.This was tested in a kind-of-an-ad-hoc "dry mode", i.e.:
Then I manually verified that the
/tmp/example.com.zonefile
had a properly updated serial number. (The actual zone update / DNS challenge will fail because I'm developing this on a laptop behind a NAT, not on an internet-facing machine with access to a DNS server.)Hope this helps!
Cheers