Hostname (Systemeinstellungen, neben Pruefintervall): - hostnamectl set-hostname ueber die App, Validierung (RFC-1123-artiges Label), kein Revert-Timer noetig (kappt die Erreichbarkeit nicht wie eine IP-Aenderung). Live getestet inkl. Validierung und Revert. DHCP: Range ist jetzt Pflicht, kein geratener Default mehr: - dhcp_range_start/end/dns starten leer (Platzhaltertext statt fake- echt aussehendem Default) - ein Zufalls-Range haette den Dienst sonst unbemerkt mit einer zum echten Netz nicht passenden Konfiguration starten lassen koennen. - write_dhcp_file und dhcp_service_action=enable_restart verweigern sich ohne eingetragene Range; _render_kea_config laesst "pools" ohne Range komplett weg statt einen kaputten Pool-String zu erzeugen. - Neues, separates dhcp_gateway-Feld (optional) fuer einen vom automatisch erkannten Gateway abweichenden Router fuer die Clients. Topbar-Ampel fuer den Kea-Dienst: - Gruener/roter Punkt neben dem Pruefintervall-Timer, nur sichtbar mit settings_dhcp.view (ein einzelner, kurzer systemctl-Aufruf pro Request, nicht die volle Status-Erkennung). Live verifiziert (rot wenn gestoppt, gruen wenn gestartet). Reservierungstabelle zeigt jetzt pro Client, welche eigene DHCP-Option greift (global oder Client-Override, mit Wert im Tooltip). Text-Straffung: die laengsten Hint-Texte und Code-Kommentare in Templates/app.py gekuerzt (u.a. groups.html, settings_dhcp.html, account.html, devices/switches/users/credentials.html, zwei grosse Migrations-/DHCP-Kommentarbloecke in app.py) - Kernaussagen erhalten, Redundanz entfernt. Quelltext-Huerde (KEINE echte Sicherheit, nur Abschreckung): Rechtsklick und DevTools-/Quelltext-Shortcuts per JS blockiert. Klar dokumentiert in Kommentar + README, dass der Browser HTML/CSS/JS immer vollstaendig ausliefert und das in Sekunden umgehbar ist - echte Absicherung bleiben ausschliesslich die serverseitigen Rechteprüfungen. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
323 lines
16 KiB
HTML
323 lines
16 KiB
HTML
{% extends "base.html" %}
|
|
{% set active_page = "settings_dhcp" %}
|
|
{% set can_edit = current_user.has_permission('settings_dhcp.edit') %}
|
|
{% block page_title %}DHCP{% endblock %}
|
|
{% block page_sub %}<div class="topbar-sub">Reservierungen und eigene Options aus den Client-Stammdaten (Kea DHCP)</div>{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="settings-grid">
|
|
|
|
<div class="card card-pad">
|
|
<div class="section-head" style="margin-bottom:16px;">
|
|
<div>
|
|
<h2 style="font-size:16px;">DHCP-Server-Status</h2>
|
|
<div class="hint">Installation/Dienststeuerung nur über die Buttons unten.</div>
|
|
</div>
|
|
</div>
|
|
{% if status.installed %}
|
|
<div class="flex gap-2" style="align-items:center; margin-bottom:10px; flex-wrap:wrap;">
|
|
<span class="pill online">Installiert</span>
|
|
{% if status.active is sameas true %}
|
|
<span class="pill online">Dienst aktiv</span>
|
|
{% elif status.active is sameas false %}
|
|
<span class="pill offline">Dienst inaktiv</span>
|
|
{% else %}
|
|
<span class="pill unknown">Dienst-Status unbekannt</span>
|
|
{% endif %}
|
|
{% if status.enabled is sameas true %}<span class="pill user">Autostart an</span>{% endif %}
|
|
</div>
|
|
{% if status.version %}<div class="text-faint mono" style="font-size:12px; margin-bottom:12px;">{{ status.version }}</div>{% endif %}
|
|
{% if can_edit %}
|
|
<div class="flex gap-2" style="flex-wrap:wrap;">
|
|
<form method="post" data-confirm="{{ dhcp_service }} aktivieren und (neu) starten? Übernimmt die zuletzt geschriebene Konfiguration.">
|
|
<input type="hidden" name="dhcp_service_action" value="enable_restart">
|
|
<button type="submit" class="btn btn-secondary btn-sm">Aktivieren & (neu) starten</button>
|
|
</form>
|
|
{% if status.active is sameas true %}
|
|
<form method="post" data-confirm="{{ dhcp_service }} stoppen? Der DHCP-Dienst vergibt danach keine Adressen mehr.">
|
|
<input type="hidden" name="dhcp_service_action" value="stop">
|
|
<button type="submit" class="btn btn-secondary btn-sm" style="color:var(--danger);">Stoppen</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
{% else %}
|
|
<span class="pill disabled">Nicht installiert</span>
|
|
<p class="text-faint" style="font-size:11.5px; margin:10px 0;">
|
|
Kein <code>kea-dhcp4</code> auf diesem Host gefunden.
|
|
</p>
|
|
{% if can_edit %}
|
|
<form method="post" data-confirm="{{ dhcp_package }} jetzt installieren (apt-get)? Startet den Dienst noch nicht.">
|
|
<input type="hidden" name="install_dhcp_package" value="1">
|
|
<button type="submit" class="btn btn-primary btn-sm">{{ dhcp_package }} installieren</button>
|
|
</form>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="card card-pad">
|
|
<div class="section-head" style="margin-bottom:16px;">
|
|
<div>
|
|
<h2 style="font-size:16px;">Netzwerk-Konfiguration</h2>
|
|
<div class="hint">Subnet/Netzmaske/Gateway werden live vom gewählten Interface übernommen, nicht manuell gepflegt.</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if net_info.ok %}
|
|
<div class="flex gap-2" style="align-items:center; margin-bottom:16px; flex-wrap:wrap;">
|
|
<span class="pill online">Erkannt</span>
|
|
<span class="mono" style="font-size:12.5px;">{{ net_info.ip }}/{{ net_info.prefix }} (Netz {{ net_info.network }})</span>
|
|
{% if net_info.gateway %}<span class="text-faint mono" style="font-size:12px;">Gateway {{ net_info.gateway }}</span>{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<div class="flex gap-2" style="align-items:center; margin-bottom:16px;">
|
|
<span class="pill offline">Nicht erkannt</span>
|
|
<span class="text-faint" style="font-size:12px;">{{ net_info.error }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if can_edit %}
|
|
<form method="post">
|
|
<input type="hidden" name="save_dhcp_config" value="1">
|
|
<div class="field"><label>Interface</label>
|
|
<select name="dhcp_interface">
|
|
{% for iface in interfaces %}
|
|
<option value="{{ iface }}" {% if iface == cfg.dhcp_interface %}selected{% endif %}>{{ iface }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<div class="field-hint">Subnet/Netzmaske/Gateway oben werden für das hier ausgewählte Interface erkannt.</div>
|
|
</div>
|
|
<div class="field"><label>Range Start</label>
|
|
<input type="text" name="dhcp_range_start" value="{{ cfg.dhcp_range_start }}" placeholder="z.B. 192.168.1.100" required>
|
|
</div>
|
|
<div class="field"><label>Range Ende</label>
|
|
<input type="text" name="dhcp_range_end" value="{{ cfg.dhcp_range_end }}" placeholder="z.B. 192.168.1.200" required>
|
|
<div class="field-hint">Pflichtfeld, muss im oben erkannten Netz liegen — ohne Range startet der Dienst nicht.</div>
|
|
</div>
|
|
<div class="field"><label>Gateway (optional)</label>
|
|
<input type="text" name="dhcp_gateway" value="{{ cfg.dhcp_gateway }}" placeholder="Automatisch: {{ net_info.gateway or '—' }}">
|
|
<div class="field-hint">Nur bei abweichendem Router für die Clients nötig — leer lassen für das oben erkannte Gateway.</div>
|
|
</div>
|
|
<div class="field"><label>DNS-Server (optional)</label>
|
|
<input type="text" name="dhcp_dns" value="{{ cfg.dhcp_dns }}" placeholder="z.B. 1.1.1.1, 8.8.8.8">
|
|
<div class="field-hint">Kommagetrennt, falls mehrere.</div>
|
|
</div>
|
|
<div class="field"><label>Domain</label>
|
|
<input type="text" name="dhcp_domain" value="{{ cfg.dhcp_domain }}">
|
|
</div>
|
|
<div class="field"><label>Lease-Zeit Standard (Sek.)</label>
|
|
<input type="number" name="dhcp_lease_default" value="{{ cfg.dhcp_lease_default }}">
|
|
</div>
|
|
<div class="field"><label>Lease-Zeit Maximum (Sek.)</label>
|
|
<input type="number" name="dhcp_lease_max" value="{{ cfg.dhcp_lease_max }}">
|
|
</div>
|
|
<div class="field"><label>Ausgabepfad (Kea-Konfigurationsdatei)</label>
|
|
<input type="text" name="dhcp_output_path" value="{{ cfg.dhcp_output_path }}" class="mono">
|
|
<div class="field-hint">Standardmäßig die aktive Kea-Konfiguration. Nach dem Schreiben den Dienst per Button neu starten, damit die Änderung wirksam wird.</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary btn-block">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>
|
|
Konfiguration speichern
|
|
</button>
|
|
</form>
|
|
{% else %}
|
|
<p class="text-faint" style="font-size:12.5px;">Für Änderungen fehlt das Recht „DHCP ändern“.</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="card card-pad" style="grid-column:1 / -1;">
|
|
<div class="section-head" style="margin-bottom:16px;">
|
|
<div>
|
|
<h2 style="font-size:16px;">Eigene DHCP-Options</h2>
|
|
<div class="hint">Herstellerspezifische Options, global oder pro Client überschreibbar.</div>
|
|
</div>
|
|
{% if can_edit %}
|
|
<button type="button" class="btn btn-primary" data-open-modal="addOptionModal">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>
|
|
Neue Option
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if option_defs %}
|
|
<div class="table-wrap">
|
|
<div style="overflow-x:auto;">
|
|
<table class="data-table">
|
|
<thead><tr><th>Code</th><th>Name</th><th>Typ</th><th>Beschreibung</th><th>Globaler Wert</th><th style="width:1%;">Aktionen</th></tr></thead>
|
|
<tbody>
|
|
{% for d in option_defs %}
|
|
<tr>
|
|
<td class="mono">{{ d.code }}</td>
|
|
<td class="mono">{{ d.name }}</td>
|
|
<td>{{ d.type }}</td>
|
|
<td class="text-faint" style="font-size:12px;">{{ d.description or '—' }}</td>
|
|
<td>
|
|
{% if can_edit %}
|
|
<form method="post" class="flex gap-2">
|
|
<input type="hidden" name="save_dhcp_option_global" value="1">
|
|
<input type="hidden" name="option_def_id" value="{{ d.id }}">
|
|
<input type="text" name="value" value="{{ option_values.get(d.id, {}).get('', '') }}" style="max-width:220px;" placeholder="(nicht gesetzt)">
|
|
<button type="submit" class="btn btn-secondary btn-sm">Speichern</button>
|
|
</form>
|
|
{% else %}
|
|
{{ option_values.get(d.id, {}).get('', '—') }}
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if can_edit %}
|
|
<form method="post" data-confirm="Option „{{ d.name }}“ inkl. aller Werte/Overrides löschen?">
|
|
<input type="hidden" name="delete_dhcp_option" value="{{ d.id }}">
|
|
<button type="submit" class="icon-btn" style="color:var(--danger);" title="Löschen">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18M8 6V4a2 2 0 012-2h4a2 2 0 012 2v2m3 0l-1 14a2 2 0 01-2 2H7a2 2 0 01-2-2L4 6"/></svg>
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<p class="text-faint" style="font-size:12.5px;">Noch keine eigenen Options definiert.</p>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="card card-pad" style="grid-column:1 / -1;">
|
|
<div class="section-head" style="margin-bottom:16px;">
|
|
<div>
|
|
<h2 style="font-size:16px;">Reservierungen aus den Clients</h2>
|
|
<div class="hint">
|
|
{{ reservations|length }} aktive{{ ' Clients' if reservations|length != 1 else 'r Client' }} mit gültiger MAC + IP im konfigurierten Subnet.
|
|
{% if skipped_count %}{{ skipped_count }} aktive{{ ' Clients' if skipped_count != 1 else 'r Client' }} ohne MAC/IP übersprungen.{% endif %}
|
|
{% if out_of_subnet_count %}{{ out_of_subnet_count }} aktive{{ ' Clients außerhalb' if out_of_subnet_count != 1 else 'r Client außerhalb' }} des erkannten Netzes übersprungen.{% endif %}
|
|
</div>
|
|
</div>
|
|
{% if can_edit %}
|
|
<form method="post" data-confirm="Konfiguration nach „{{ cfg.dhcp_output_path }}“ schreiben? Der Dienst übernimmt die Änderung erst nach einem Neustart.">
|
|
<input type="hidden" name="write_dhcp_file" value="1">
|
|
<button type="submit" class="btn btn-secondary">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><path d="M14 2v6h6"/></svg>
|
|
In Datei schreiben
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% if reservations %}
|
|
<div class="table-wrap" style="margin-bottom:18px;">
|
|
<div style="overflow-x:auto;">
|
|
<table class="data-table">
|
|
<thead><tr><th>Hostname</th><th>MAC</th><th>IP-Adresse</th><th>Client-Name</th><th>Optionen</th><th style="width:1%;">Aktionen</th></tr></thead>
|
|
<tbody>
|
|
{% for r in reservations %}
|
|
<tr>
|
|
<td class="mono">{{ r.hostname }}</td>
|
|
<td class="mono">{{ r.mac }}</td>
|
|
<td class="mono">{{ r.ip }}</td>
|
|
<td>{{ r.name }}</td>
|
|
<td style="font-size:12px;">
|
|
{% for d in option_defs %}
|
|
{% set override = option_values.get(d.id, {}).get(r.mac) %}
|
|
{% set global_val = option_values.get(d.id, {}).get('') %}
|
|
{% if override %}
|
|
<span class="pill user" title="{{ d.name }} = {{ override }}">{{ d.name }} (eigen)</span>
|
|
{% elif global_val %}
|
|
<span class="pill" style="background:var(--muted-dim); color:var(--text-faint);" title="{{ d.name }} = {{ global_val }}">{{ d.name }} (global)</span>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</td>
|
|
<td>
|
|
{% if option_defs and can_edit %}
|
|
<button class="icon-btn" title="DHCP-Optionen für diesen Client" data-open-modal="deviceOptionsModal{{ loop.index }}">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6h9M17 6h3M4 12h3M11 12h9M4 18h13M20 18h0"/><circle cx="15" cy="6" r="2"/><circle cx="9" cy="12" r="2"/><circle cx="17" cy="18" r="2"/></svg>
|
|
</button>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% if option_defs and can_edit %}
|
|
<div class="modal-overlay" id="deviceOptionsModal{{ loop.index }}">
|
|
<div class="modal">
|
|
<form method="post">
|
|
<input type="hidden" name="save_dhcp_device_options" value="1">
|
|
<input type="hidden" name="mac" value="{{ r.mac }}">
|
|
<div class="modal-header">
|
|
<h3>DHCP-Optionen — {{ r.name }}</h3>
|
|
<button type="button" class="modal-close" data-close-modal>×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p class="text-faint" style="font-size:11.5px; margin:0 0 14px;">Leer lassen, um den globalen Wert zu übernehmen.</p>
|
|
{% for d in option_defs %}
|
|
<div class="field">
|
|
<label>{{ d.name }} <span class="text-faint">(Code {{ d.code }})</span></label>
|
|
<input type="text" name="opt_{{ d.id }}" value="{{ option_values.get(d.id, {}).get(r.mac, '') }}"
|
|
placeholder="{{ option_values.get(d.id, {}).get('', '(kein globaler Wert)') }}">
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-close-modal>Abbrechen</button>
|
|
<button type="submit" class="btn btn-primary">Speichern</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<p class="text-faint" style="font-size:12.5px; margin-bottom:18px;">Keine aktiven Clients mit MAC + IP vorhanden.</p>
|
|
{% endif %}
|
|
|
|
<div class="permission-group-title">Generierte Konfiguration (Vorschau, Kea-JSON)</div>
|
|
<pre class="code-preview">{{ preview }}</pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% if can_edit %}
|
|
<div class="modal-overlay" id="addOptionModal">
|
|
<div class="modal" style="max-width:1000px;">
|
|
<form method="post">
|
|
<input type="hidden" name="add_dhcp_option" value="1">
|
|
<div class="modal-header">
|
|
<h3>Neue DHCP-Option</h3>
|
|
<button type="button" class="modal-close" data-close-modal>×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="field"><label>Code</label>
|
|
<input type="number" name="code" min="1" max="254" required placeholder="z.B. 225">
|
|
</div>
|
|
<div class="field"><label>Name</label>
|
|
<input type="text" name="name" required placeholder="z.B. terminal-url" pattern="[a-z][a-z0-9-]*">
|
|
<div class="field-hint">Nur Kleinbuchstaben, Ziffern und Bindestrich, muss mit einem Buchstaben beginnen.</div>
|
|
</div>
|
|
<div class="field"><label>Datentyp</label>
|
|
<select name="type">
|
|
{% for key, label in option_types %}
|
|
<option value="{{ key }}">{{ label }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="field"><label>Beschreibung</label>
|
|
<input type="text" name="description" placeholder="z.B. Terminal-Boot-URL für Thin Clients">
|
|
</div>
|
|
<div class="field"><label>Globaler Wert (optional)</label>
|
|
<input type="text" name="initial_value" placeholder="z.B. http://bde/webmmi?M=SGM11">
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-close-modal>Abbrechen</button>
|
|
<button type="submit" class="btn btn-primary">Anlegen</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% endblock %}
|