Остання активність 2 weeks ago

Creates a mass of listed names CNAME records on Hetzner DNS Cloud.

dominic ревизій цього gist 2 weeks ago. До ревизії

2 files changed, 66 insertions

README.md(файл створено)

@@ -0,0 +1,51 @@
1 + ## Explained
2 +
3 + I tried the quick route by adding a wildcard CNAME record to handle all possible
4 + subdomains quickly. Turns out, that ACME client (Let's Encrypt) does not like that
5 + (or at least: my client that tries to get new certificates).
6 +
7 + So I removed it but I had to put around 30 subdomains into the zonefile.
8 + I could have done that quickly with the texteditor of choice but I wanted
9 + something modular, something that I can use later again.
10 +
11 + ### The procedure
12 +
13 + I had all the subdomains n my local DNS server (I'm using split DNS at home)
14 + but OPNSense does not have an export feature in there so I copied them all
15 + with the mouse and pasted them into a textfile `vhosts`.
16 +
17 + Now I had something like this:
18 +
19 + ```
20 + cadence.oe7drt.net
21 + it-tools
22 + cadence.oe7drt.net
23 + kamera
24 + cadence.oe7drt.net
25 + host3
26 + cadence.oe7drt.net
27 + host4
28 + ...
29 + ```
30 +
31 + They've been all in lines on the webinterface but now they are all separated
32 + by newlines. As they are consistently changing lines I decided to only extract
33 + every 2nd line, which worked pretty well.
34 +
35 + ```console
36 + $ awk 'NR % 2 == 0' vhosts | xargs
37 + ```
38 +
39 + I copied the result into my new script and executed it.
40 +
41 + Et voilà!
42 + The script pushed them all to the DNS server blazing fast. I'm sure we could tighten
43 + them all together and send them with only one request but that is an option for someone
44 + else ;-P
45 +
46 + My quick-n-dirty solutions have never been elegant but they work most of the time (even if
47 + they work only for a short time, they help me overcome the weirdest encounters) \*lol*
48 +
49 + Read more (sources)
50 +
51 + - <https://docs.hetzner.cloud/reference/cloud#zone-rrsets-create-an-rrset>

create-cname.sh(файл створено)

@@ -0,0 +1,15 @@
1 + #!/bin/sh
2 +
3 + HETZNER_API_TOKEN=""
4 + CNAME_TARGET="basedomain.local."
5 + ZONEID="basedomain.local"
6 +
7 + for SUBDOMAIN [it-tools kamera host3 host4 ...]
8 + do
9 + curl \
10 + -X POST \
11 + -H "Authorization: Bearer $HETZNER_API_TOKEN" \
12 + -H "Content-Type: application/json" \
13 + -d '{"name":"'$SUBDOMAIN'","type":"CNAME","ttl":300,"records":[{"value":"'$CNAME_TARGET'","comment":""}]}' \
14 + "https://api.hetzner.cloud/v1/zones/$ZONEID/rrsets"
15 + done
Новіше Пізніше