site-josuah

/usr/josuah
Log | Files | Refs

commit 1b991875830c8e6e3ceda3840a9f773cbf7c26dc
parent e1935709a25ce4e1f6d4a3c50d20110cb8531532
Author: Josuah Demangeon <me@josuah.net>
Date:   Mon, 20 Apr 2020 02:15:56 +0200

wiki/tinydns: bootstrap nameservers

Diffstat:
M.githooks/post-update | 2+-
Mindex.md | 1-
Awiki/tinydns/Makefile | 14++++++++++++++
Mwiki/tinydns/index.md | 44++++++++++++++++++--------------------------
Awiki/tinydns/push.awk | 9+++++++++
5 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/.githooks/post-update b/.githooks/post-update @@ -1,8 +1,8 @@ #!/bin/sh -ex # deploy the website to /srv - tmp=$(git-hooks-workdir "$@") trap 'rm -rf "$tmp"' INT TERM EXIT HUP + cd "$tmp" notwiki-doc html "/srv/www/htdocs/josuah" * diff --git a/index.md b/index.md @@ -31,4 +31,3 @@ You can access to this server through tor: gopher: xy4ahbltrqxpl7uiwpmabjmrzb52ghgb64rs5wqf2dhf4kowjnw6vcid.onion http: zlo3b54hcz7idqgev3t2iesmaojahlhyxeuaoubwbpjsfmijfnjwmtad.onion smtp: gmbrpfu2w6hlxgqj3nak7apfhi3a77zl4msh3mm3wtib2rlnmhcj32yd.onion - diff --git a/wiki/tinydns/Makefile b/wiki/tinydns/Makefile @@ -0,0 +1,14 @@ +all: data.cdb + +data = rr.soa rr.host rr.alias rr.mx rr.ns +data: data.awk ${data} + awk -f data.awk ${data} >$@ + +data.cdb: data + tinydns-data + +clean: + rm -f data data.cdb + +push: data.cdb rr.host rr.ns + awk -f push.awk rr.host rr.ns diff --git a/wiki/tinydns/index.md b/wiki/tinydns/index.md @@ -20,13 +20,16 @@ information: entries on some of these IPs. To achieve this, I use these *input files*, that get converted into ./data by -an awk script /etc/tinydns/[[data.awk]]: +an awk script [[data.awk]], and publish from a [[push.awk]], both run from a +[[Makefile]]. [data.awk]: /wiki/tinydns/data.awk +[push.awk]: /wiki/tinydns/push.awk +[makefile]: /wiki/tinydns/Makefile -/etc/dns/rr.domain ------------------- +/etc/tinydns/rr.domain +---------------------- A list of top and second level domain names. The first one listed is the "technical" domain name. @@ -57,8 +60,8 @@ We now have matching MX, A, AAAA and PTR entries. kuntur -/etc/dns/rr.ns --------------- +/etc/tinydns/rr.ns +------------------ A list of hostnames that run a DNS name server. Like for "rr.mx", each domain in "rr.domain" gets one NS record per name server listed here. @@ -66,33 +69,22 @@ in "rr.domain" gets one NS record per name server listed here. harpyja ns2 -/etc/dns/rr.alias ------------------ +/etc/tinydns/rr.alias +--------------------- A list of regular domain records for your various servers and services. You may harpyja www.josuah.net harpyja git.josuah.net kuntur josuah.z0.is -In the end you have a clear model that you build for yourself that fully -leverage the DNS zone challenges. - -New computer, mail servers, name servers, top level domain... are added by a -single line on one of these files (same goes for removal). -You never have to copy-paste IPs, nor maintain consistency between different -records. Each information is held at only at one place. +Maintaining records +------------------- +"make push" update all necessary parts and calls push.awk, which looks at the +rr.host to get the IPs, and rr.ns for where to deploy them, then scp data.cdb +to all nameserver found. -I run it in a makefile like this: +This effectively update the DNS records sending about 5KB of data over SSH: +about 1.50 second over a DSL line for 2 nameservers. - all: data.cdb - - data = rr.domain rr.host rr.alias rr.mx rr.ns - data: data.awk ${data} - awk -f data.awk ${data} >$@ - - data.cdb: data - tinydns-data - - clean: - rm -f data data.cdb +This permits to bootstrap DNS data without the need to configure /etc/hosts. diff --git a/wiki/tinydns/push.awk b/wiki/tinydns/push.awk @@ -0,0 +1,9 @@ +#!/usr/bin/awk -f + +FILENAME == "rr.host" { + ip[$1] = $2 +} + +FILENAME == "rr.ns" { + system("scp 'data.cdb' 'root@"ip[$1]":/etc/tinydns/data.cdb'") +}