Files
nilsandClaude Sonnet 5.5 2eab735f59 Publish DHCP clients' names in DNS
router-webui leases-dns reads Kea's leases and publishes <name>.<domain>
with reverse records in the running Unbound (router.dns.dynamicLeases).
Names the configuration publishes are never taken over; a client's name
is cut to its first label and kept inside the local domain; of two
clients the newer lease wins. The DNS page switches it on and shows what
is published and what was skipped; router-setup enables it with a domain.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
2026-10-30 00:18:01 +01:00

89 lines
4.3 KiB
HTML

{{define "content"}}
{{with .Data}}
{{$e := .Errors}}
<form method="post" action="/dns">
<input type="hidden" name="csrf" value="{{$.CSRF}}">
<fieldset>
<legend>Records</legend>
<input type="hidden" name="recs" value="{{len .Records}}">
<div class="scroll">
<table>
<tr><th>Name</th><th>Addresses</th><th>Remove</th></tr>
{{range $i, $r := .Records}}
<tr>
<td><input name="rec.{{$i}}.name" value="{{$r.Name}}" size="30" spellcheck="false" placeholder="nas or *.k8s.example.org"></td>
<td><input name="rec.{{$i}}.addresses" value="{{$r.Addresses}}" size="40" spellcheck="false" placeholder="192.168.10.20, fd00::20"></td>
<td>{{if $r.Name}}<input type="checkbox" name="rec.{{$i}}.remove">{{end}}</td>
</tr>
{{range $f := list "name" "addresses"}}{{with index $e (printf "rec[%d].%s" $i $f)}}<tr><td colspan="3" class="field-error">{{$f}}: {{.}}</td></tr>{{end}}{{end}}
{{end}}
</table>
</div>
<p class="hint">An IPv4 address becomes an A record, an IPv6 address an AAAA record; several addresses give several records.
A name without a dot lives in the local domain{{if .Domain}} (<code>{{.Domain}}</code>){{else}} (none is set: do that on the Network page){{end}}.
A full name such as <code>photos.example.org</code> overrides public DNS for just that name.</p>
<p class="hint"><code>*.k8s.example.org</code> is a wildcard: <code>k8s.example.org</code> itself and every name below it
(<code>a.k8s.example.org</code>, <code>x.y.k8s.example.org</code>) answer with these addresses.</p>
</fieldset>
<fieldset>
<legend>Forward zones</legend>
<input type="hidden" name="zones" value="{{len .Zones}}">
<table>
<tr><th>Domain</th><th>Resolvers</th><th>Remove</th></tr>
{{range $i, $z := .Zones}}
<tr>
<td><input name="zone.{{$i}}.name" value="{{$z.Name}}" size="30" spellcheck="false" placeholder="branch.example.org"></td>
<td><input name="zone.{{$i}}.addresses" value="{{$z.Addresses}}" size="30" spellcheck="false" placeholder="10.1.0.254"></td>
<td>{{if $z.Name}}<input type="checkbox" name="zone.{{$i}}.remove">{{end}}</td>
</tr>
{{range $f := list "name" "addresses"}}{{with index $e (printf "zone[%d].%s" $i $f)}}<tr><td colspan="3" class="field-error">{{$f}}: {{.}}</td></tr>{{end}}{{end}}
{{end}}
</table>
<p class="hint">Names below these domains are asked from these resolvers (for example across a tunnel), not from the internet.</p>
</fieldset>
<fieldset>
<legend>DHCP clients</legend>
<label><input type="checkbox" name="dynamic" {{if .Dynamic}}checked{{end}}> Publish the names of DHCP clients as <code>name.{{if .Domain}}{{.Domain}}{{else}}domain{{end}}</code></label>
{{if and .Dynamic (not .Domain)}}<p class="field-error">This needs a local domain (Network page).</p>{{end}}
<p class="hint">A client chooses its own name, so only its first label is used, only in your local domain, and a name
that is configured here (a record above, a reservation, the router itself, a wildcard) is never taken over.
Of two clients with one name the newer lease wins. Takes effect when applied.</p>
</fieldset>
<button>Save</button>
</form>
{{if .Dyn}}
<section>
<h2>DHCP clients in DNS</h2>
{{if .Dyn.Error}}<p class="field-error">The last update failed: {{.Dyn.Error}}</p>{{end}}
{{if .Dyn.Published}}
<table>
<tr><th>Name</th><th>Address</th></tr>
{{range .Dyn.Published}}<tr><td>{{.Name}}</td><td>{{.Address}}</td></tr>{{end}}
</table>
{{else}}<p class="muted">No client names are published at the moment.</p>{{end}}
{{if .Dyn.Skipped}}
<p class="hint">Not published:</p>
<table>
<tr><th>Client name</th><th>Address</th><th>Why</th></tr>
{{range .Dyn.Skipped}}<tr><td>{{.Hostname}}</td><td>{{.Address}}</td><td>{{.Reason}}</td></tr>{{end}}
</table>
{{end}}
<p class="hint">As of {{ago .Dyn.Updated}} ago, from the running configuration.</p>
</section>
{{else if .Dynamic}}
<p class="hint">Client names are not published yet: apply the settings so the service starts.</p>
{{end}}
{{if .Auto}}
<section>
<h2>Published automatically</h2>
<ul>{{range .Auto}}<li>{{.}}</li>{{end}}</ul>
<p class="hint">The router's own name and the DHCP reservations (edit those on the DHCP page).</p>
</section>
{{end}}
{{end}}
{{end}}