Initial commit: DHCP Web Manager

Flask-based web UI for managing ISC DHCP server (dhcpd).

Features:
- subnet / static host binding CRUD via web
- listen interface configuration (INTERFACESv4)
- active lease query + pool utilization stats
- service status, reload/restart, syntax check
- user auth + operation logs
- automatic backup before each config change
- safe change pipeline: write file → dhcpd -t → systemctl restart + is-active verify
- error messages include journalctl tail for diagnosis
This commit is contained in:
DHCP Service Bot
2026-07-09 17:09:23 +08:00
commit 90736253b1
18 changed files with 2192 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
{% extends "base.html" %}
{% block title %}子网配置{% endblock %}
{% block content %}
<div class="page-head">
<h1>子网配置</h1>
{% if is_admin %}<a href="{{ url_for('subnet_new') }}" class="btn btn-primary">+ 新增子网</a>{% endif %}
</div>
{% if subnets %}
<table class="data-table">
<thead>
<tr>
<th>网段</th>
<th>掩码</th>
<th>网关</th>
<th>DNS</th>
<th>地址池</th>
<th>租期(默认/最大)</th>
<th>authoritative</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for s in subnets %}
<tr>
<td><code>{{ s.network }}</code></td>
<td><code>{{ s.netmask }}</code></td>
<td><code>{{ s.routers }}</code></td>
<td><code>{{ s.dns }}</code></td>
<td><code>{{ s.range_start }}<br>~ {{ s.range_end }}</code></td>
<td>{{ s.default_lease }}s / {{ s.max_lease }}s</td>
<td>{% if s.authoritative %}<span class="badge badge-ok">yes</span>{% else %}<span class="muted">no</span>{% endif %}</td>
<td class="actions">
{% if is_admin %}
<a href="{{ url_for('subnet_edit', network=s.network, netmask=s.netmask) }}" class="btn btn-sm">编辑</a>
<form method="post" action="{{ url_for('subnet_delete', network=s.network, netmask=s.netmask) }}"
onsubmit="return confirm('确认删除子网 {{ s.network }}/{{ s.netmask }}');" style="display:inline">
<button type="submit" class="btn btn-sm btn-danger">删除</button>
</form>
{% else %}
<span class="muted"></span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="card empty">
<p>暂无子网配置</p>
{% if is_admin %}<a href="{{ url_for('subnet_new') }}" class="btn btn-primary">+ 新增第一个子网</a>{% endif %}
</div>
{% endif %}
{% endblock %}